home *** CD-ROM | disk | FTP | other *** search
/ PC Open 105 / PC Open 105 CD 1.bin / CD1 / INTERNET / COPIA SITI / Getleft / getleft-setup-notcl.exe / {app} / scripts / help.tcl < prev    next >
Encoding:
Text File  |  2003-05-26  |  110.0 KB  |  3,108 lines

  1. ################################################################################
  2. #      
  3. #  Project       :  Help System
  4. #
  5. #  Developed by  :  Andrei A. Gratchev      <grand@deversys.com>
  6. #
  7. #  Filename      :  help.tcl
  8. #  Version       :  1.5
  9. #  Description   :  Help system based on HTML & HTML viewer
  10. #
  11. ################################################################################
  12.                                                                                
  13. package provide help 1.5
  14.  
  15. namespace eval help {
  16.  variable w
  17.  variable gw
  18.  variable abort         0
  19.  variable showing       0
  20.  variable stat          ""
  21.  variable curfilename   ""
  22.  variable data
  23.  variable history       ""
  24.  variable hpos          0
  25.  variable index         ""
  26.  variable attr
  27.  variable perc
  28.  variable font          "Helvetica"
  29.  variable fontfixed     "Courier"
  30.  variable fontsize      12
  31.  variable backcolor     ""
  32.  variable forecolor     black
  33.  variable linkcolor     "#006800"
  34.  variable alinkcolor    "#c00000"
  35.  variable lmargin       6
  36.  variable rmargin       6
  37.  variable settings
  38.  variable curtopic      ""
  39.  variable _count
  40.  variable _tags
  41.  variable _images
  42.  array set _images "broken  [image create photo -data "R0lGODlhIAAgALP/AP///8DAwP8A/7+/v39/f38AfwD//wB/AAAA/wAAfwAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAgACAAAAT/kMhJq50h60yA/2AoAtKmdWMqEgNhBuggz3Rdd60Z35NNx66Th3c4EBJI1u2T4wxnEhLyk/yBmjsZwZgYJZStUC7bOnRTX5lizV7Dntrj54iSQiuKN+B3BiAVUx5pcRN5ZAN9CQoSiWAzHoZwMkiUjHWDNJB6NhVfc5iPAJF7PpYgioWhoy0+np8ECAaoMppACjZ9UosGCKgstUMdtzR9R7sIvYu/opsow5NUx8i+A8B7HQKiM5RJvMjJEtXMQAAC2cPcX9/TyuKr2AIF2o3p1NZh5gXnjW1s4ffY9MUT0OjCv3HBABRYyDCdwYPv4j0M54MWwj39Mj6r6G5Ti4mOGHzcI/SQY8c6KlKOGKWyJYg8GmPK1BggAgA7"]
  43.                     disc    [image create photo -data "R0lGODlhEAAFAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAUAAAINhA+hyKff2FvRzYogKwA7"]
  44.                     circle  [image create photo -data "R0lGODlhEAAHAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAcAAAIShA+hyBfe0JPRTFivrbvztDAFADs="]
  45.                     square  [image create photo -data "R0lGODlhEAAFAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAUAAAINhB+Zx6zb2gtRvuouKwA7"]
  46.                     ugol    [image create photo -data "R0lGODlhDAAMAJH/AP///8DAwH9/fwAAACH5BAEAAAEALAAAAAAMAAwAAAIbjI8BmSB83IMSKvFWw3dnHnFV+GVGhZZXmaoFADs="]
  47.                     d1      [image create photo -data "R0lGODlhEAAQAPf/AP///////P//+///7///6f//5f//5P//4f//3P//2f//0v//z///zv//zf//zP//y///yv//yf//x///xv//xf//xP//wv/+5v/+1f/82//82v/81//81v/81f7/8/783v373Pv9x/v9vfr9zPn5+vn5+fn57/n57ff7yfX4v/T68uv0w+Dvrdvtr9TU19TU0dTT19PptNLS1dLS0tLS0dLSz8znoczMzszMzMvLy8nkxsnIksjjw8fHx8fHwMbGxsLCwsHBwcDAwL+/v76+vri4uLbiyLGxsbCwsK+vr6ampqWlpaGhoaCgoJaWmJaWlpOTk5KSko+Pj4yMjIvFa4mJiX7HsHq+YXJycmy2WmmzRmSyV2Cfe16uN1udkVqsM1RUVE2XhExJTkpIPkhFSURBRkI/R0I/RkGgFD2dEzo4OSWSCiKQAB0cHRyAaxcWFwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAEAAQAAAI0QDhCBxIsOAQOEESKly4EAAcIEeiPJn4xIkTKEp+EBniEEgTHCVCkjhhwgWYKTmIdGQyA4BLDxUY+LiBpcqPlS1dKuiiYscYMW+KrJRhgICOLWy+KHgQgEySlTUcpHBjJA0PBREwnEECdcEKLgVYJAghYcPWlTQAHBABocUHLw0ynH3IhKiFEVS0WAkTdy4QJjUeOIixBk0WFGXnBmHyogGFBTauDJggQStXOD2WwLiQgQMCEBo2dBDg1KEQKWrKnDFj5sxqM2TaCOXosrbt2wEBADs="]
  48.                     d2      [image create photo -data "R0lGODlhEAAQAPf/AP///////f///P//+///9///8v//5v//5P//4///4f//3///3f//2///2f//2P//1P//0P//zv//y///yv//yf//yP//x///xf//w///wP/+5f/+2f/+1f/82//81//81v/81f7+v/v96vv9zPn7yPn5+vn5+fn57/n57fj8uPb7xvT7xvH3/vH2wNrvldTpndTU19TU0dTT19LpxtLS1dLS0tLS0dLSz8/pgc/MkMzMzszMzMvLy8nmrsnfwsfHx8fHwcbGxsLCwsHiq8HBwcDAwL+/v76+vr3hpby8vLvdrri4uLe4t7XadLKysrGxsbCw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1y/PBYZQaAlwMsQOhxA4wXJSxdvjxQYcEONGbmQGEpg0CUMF9ATFgAIUCaJyxrMPBBJ44IFDYebHADFWKVGgrGFBGT4kQdHRq4sqQBgI0QBy5UULlyQK1XGQaWqEnQ5EwZJAjsAvn6IEIIBUnsvGnBwW6QKjAaUJAQYcURJiwUuBl6h8eUGBc6ePiAocCBDALS4LwzhAucNW7atHETu00aOQ4dvtzNu3dAADs="]
  50.  
  51.                     back    [image create photo -data "R0lGODlhDwANAKL/AM///8DAwJD//y/I/y+X/y9n/wAAAAAAACH5BAEAAAEALAAAAAAPAA0AAAM0GLq2/qE0+AqYVFmB6eZFKEoRIAyCaaYCYWxDLM9uYBAxoe/7dA8ug3AoZOg6mRsyuUxmEgA7"]
  52.                     forward [image create photo -data "R0lGODlhDwANAKL/AM///8DAwJD//y/I/y+X/y9n/wAAAAAAACH5BAEAAAEALAAAAAAPAA0AAAM3GLpa/K8YSMuYlBVwV/kgCAhdsAFoig7ktA1wLA9SQdw4DkuB4f8/Ag2TMRB4GYUBmewRm09FAgA7"]
  53.                     stop    [image create photo -data "R0lGODlhDQANALP/AP///1Lq81I5Of+EhCEAAHsAAMYAAP+UQv9zCHuMjP8AMf8AKf+MnK1CSv8QIQAAACH5BAEAAAEALAAAAAANAA0AAARWMMjUTC1J6ubOQYdiCBuIIMuiiCT1OWu6Ys05AMPC4ItBGB8dYMdI+RoHR4qY6v1CwlvRcEQ4brndwFAgJAwIRdPIzVTEYiqXJBEU1FQCW5Mg2O0ZSQQAOw=="]
  54.                     refresh [image create photo -data "R0lGODlhDAANALP/AP///zk5OVJSUoSEhKWlpcDAwP//1v//xr3erZTOezGcEFKtSimce3NzezkxOQAAACH5BAEAAAUALAAAAAAMAA0AAARRcJBJyRilEMC5AcjQaB1wHMYkCFuXLKDQONsBLIuynEBAGAcJAnYy0AyGBOLENPg4qGUISTMdEIoEg4A6ohK6BND4YyqBqCdyve453vB44BEBADs="]
  55.  
  56.                     inc     [image create photo -data "R0lGODlhDAAMAJECAICAgAAAAP///wAAACH5BAEAAAIALAAAAAAMAAwAAAIglH+BphxtQADi2fTWkY9qdS2S42HWtECVOmJleGqyUQAAOw=="]
  57.                     dec     [image create photo -data "R0lGODlhDAAMAJECAICAgAAAAP///wAAACH5BAEAAAIALAAAAAAMAAwAAAIalC+hirjdApyUygoCqG/mtEEL03yGFjHdUQAAOw=="]
  58.                     cont    [image create photo -data "R0lGODlhDAAMALMAADg4ONDQ0AEBAZqamv///4aGhrCwsGdnZ2wCAgCYmIaenoaGnj8/BJiYAAQ/P56GhiH5BAAAAAAALAAAAAAMAAwAAARBkAwhACGADqJJOEcgUcAwAGVxKQiSeoKBGqQ5C2JxvkF8VwPVSLRoMEq74GUCVPU2hEfCAaABTxTSBYbbZrJgcAQAOw=="]
  59.                     index   [image create photo -data "R0lGODlhDAAMAKIEAACAAP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMpSLM89G+IMMWCimrpogWAxURaRXUcqAZoWaKfCrCkWcGDPLf2GTVAQgIAOw=="]
  60.                     find    [image create photo -data "R0lGODlhDAAMAJEDAMDAwP///wAAAP///yH5BAEAAAMALAAAAAAMAAwAAAIgnI8oaysa3hDxuMtadFtegE3UAnYYh3XiuGzQqTjJPBQAOw=="]
  61.                     search  [image create photo -data "R0lGODlhDAAMALMPADExMP//j2hoaGFhLgEBAYWFhe3t7a2tqv39aNPT0xcXFqGhH1BQXCoqHQgICv///yH5BAEAAA8ALAAAAAAMAAwAAARV8LR2kk3m6RZCGeAgaA/QIV0HkByKBgiQlafSLIECHA8XHAoBY6Eo8BggR4HAXMoMlgaAIJAyExoB4UAFJJiOLIMJUAKmWYNDdii4CdmGY/QwKBSOCAA7"]
  62.                     open    [image create photo -data "R0lGODlhDAAMALMPAOvr605OOfv7iDk5FbGxsZ2dNM3NzY2NjcrKXYaGAImJABoaCIuLABkZAGFhYf///yH5BAEAAA8ALAAAAAAMAAwAAARJ8EkJyBhmanAeDwTXaY/TEE5ROCxrHAcQCAJiIw4xzXSfhAAZrdAoFheNwawwYCieDEZAhhgkrlcF5rGwMrCMLbexKJt1pPQkAgA7"]
  63.                     reload  [image create photo -data "R0lGODlhDAAMAKIHAO3tYefnnkVFQTExgzc3J29vf8DAXv///yH5BAEAAAcALAAAAAAMAAwAAAM7eEJ8/sqAYAR0ZE7GyQqTURSGQTFTMYwDGHzGoI3gAtDTsL4EJYMqiS2gKrgmCwmloDl5BNBF1HOpHhIAOw=="]
  64.                     prev    [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMpSLM89G+IMMWCimrpYqUAE2kCAFCdBJpTupqo97ZjBVuyTWdflTZAQgIAOw=="]
  65.                     up      [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMnSLM89G+IMMWCimrpYt1XVgFVJ1FAOploqpqCK7Nf6WkfjVNm4xMJADs="]
  66.                     next    [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//////AAAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMrSLM89G8EMcOCimrp4gTblQUAWHWSUJoCSq0m+pVb9LKWp2qTW/GohpCQAAA7"]
  67.  "
  68.  variable btninfo
  69. #Controls/buttons:  link_name     text/hint  vis_cond  activ_cond  button_name
  70.  array set btninfo "__prev     {[list "Back"     1 {$help::hpos>0} "bback"]}
  71.                     contents   {[list "Contents" 1 {[lsearch $help::index "contents"]!=-1} "bcont"]}
  72.                     __dec      {[list "Decrease" 1 {$help::fontsize>6} "bdec"]}
  73.                     __find     {[list "Find"     1 1 "bfind"]}
  74.                     __next     {[list "Forward"  1 {$help::hpos<[expr [llength $help::history] - 1]} "bforward"]}
  75.                     __inc      {[list "Increase" 1 {$help::fontsize<30} "binc"]}
  76.                     __index    {[list "Index"    1 {$help::index!=""} "bindex"]}
  77.                     __Next     {[list "Next"     {$help::h4contents!=""} {[lsearch $help::sequence $help::curtopic]<[expr [llength $help::sequence] - 1] && [lsearch $help::sequence $help::curtopic]>-1} "bnext"]}
  78.                     __open     {[list "Open"     1 1 "bopen"]}
  79.                     __Prev     {[list "Previous" {$help::h4contents!=""} {[lsearch $help::sequence $help::curtopic]>0} "bprev"]}
  80.                     __refresh  {[list "Refresh"  1 1 "brefresh"]}
  81.                     __reload   {[list "Reload"   1 1 "breload"]}
  82.                     __search   {[list "Search"   1 {$help::index!=""} "bsearch"]}
  83.                     __stop     {[list "Stop"     1 {$help::showing || $help::insearch} "bstop"]}
  84.                     __up1level {[list "UpLevel"  {$help::h4contents!=""} {[array names help::up1level $help::curtopic]!=""} "bup"]}
  85.  "
  86.  variable _istitle      0
  87.  variable _isscript     0
  88.  variable _istext       1
  89.  variable _t_title
  90.  variable _dnum         1
  91.  variable _focus_w      ""
  92.  variable _need_tag
  93. #sch
  94.  variable up1level 
  95.  variable sequence      ""
  96.  variable hcontents     ""
  97.  variable h2ignore      ""
  98.  variable h4topics      ""
  99.  variable h4contents    ""
  100. #/sch
  101.  variable h_appendlist  1
  102.  array set settings     "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
  103.  variable fnd_str       ""
  104.  variable fnd_len
  105.  variable fnd_case      "-nocase"
  106.  variable fnd_regexp    ""
  107.  variable fnd_direction "-forwards"
  108.  variable searchedtext  ""
  109.  variable insearch      0
  110.  variable controls
  111.  variable buttons
  112.  variable interp
  113.  variable tables
  114.  array set tables       "level 0 stack {} count 0 tables {}"
  115.  variable ext_loaded    ""
  116. }
  117.  
  118. #===============================================================================
  119.  
  120. #-------------------------------------------------------------------------------
  121. # Functions      :  help::tag_*
  122. # Description    :  Process corresponding open/close tag
  123. # Parameters     :  params      - arguments of tag
  124. # Return         :  Nothing
  125. #-------------------------------------------------------------------------------
  126. proc help::tag_\$ {params} {
  127.  variable data
  128.  upvar _text _text
  129.  
  130.  foreach {param value} $params {
  131.   if {[info exists data(subst,$param,begin)]} {
  132.    set _text "$data(subst,$param,begin)$_text"
  133.   }
  134.   break
  135.  }
  136. }
  137.  
  138. proc help::tag_/\$ {params} {
  139.  variable data
  140.  upvar _text _text
  141.  
  142.  foreach {param value} $params {
  143.   if {[info exists data(subst,$param,end)]} {
  144.    set _text "$data(subst,$param,end)$_text"
  145.   }
  146.   break
  147.  }
  148. }
  149.  
  150. proc help::tag_center {params} {
  151.  variable w
  152.  variable attr
  153.  
  154.  set attr(justify,global) [linsert $attr(justify,global) 0 "center"]
  155.  if {[$w.text get "end -2c"]!="\n"} {
  156.   $w.text insert end "\n" [gettags]
  157.  }
  158. }
  159.  
  160. proc help::tag_/center {params} {
  161.  variable w
  162.  variable attr
  163.  
  164.  catch {set attr(justify,global) [lreplace $attr(justify,global) 0 0]}
  165.  if {[$w.text get "end -2c"]!="\n"} {
  166.   $w.text insert end "\n" [gettags]
  167.  }
  168. }
  169.  
  170. proc help::tag_b {params} {
  171.  variable attr
  172.  
  173.  set attr(style) [linsert $attr(style) 0 "b"]
  174. }
  175.  
  176. proc help::tag_/b {params} {
  177.  variable attr
  178.  
  179.  if {[set pos [lsearch $attr(style) "b"]]!=-1} {
  180.   set attr(style) [lreplace $attr(style) $pos $pos]
  181.  }
  182. }
  183.  
  184. proc help::tag_i {params} {
  185.  variable attr
  186.  
  187.  set attr(style) [linsert $attr(style) 0 "i"]
  188. }
  189.  
  190. proc help::tag_/i {params} {
  191.  variable attr
  192.  
  193.  if {[set pos [lsearch $attr(style) "i"]]!=-1} {
  194.   set attr(style) [lreplace $attr(style) $pos $pos]
  195.  }
  196. }
  197.  
  198. proc help::tag_u {params} {
  199.  variable attr
  200.  
  201.  set attr(style) [linsert $attr(style) 0 "u"]
  202. }
  203.  
  204. proc help::tag_/u {params} {
  205.  variable attr
  206.  
  207.  if {[set pos [lsearch $attr(style) "u"]]!=-1} {
  208.   set attr(style) [lreplace $attr(style) $pos $pos]
  209.  }
  210. }
  211.  
  212. proc help::tag_pre {params} {
  213.  variable attr
  214.  
  215.  set attr(style) [linsert $attr(style) 0 "p"]
  216. }
  217.  
  218. proc help::tag_/pre {params} {
  219.  variable attr
  220.  
  221.  if {[set pos [lsearch $attr(style) "p"]]!=-1} {
  222.   set attr(style) [lreplace $attr(style) $pos $pos]
  223.  }
  224. }
  225.  
  226. proc help::tag_nobr {params} {
  227.  variable attr
  228.  
  229.  set attr(style) [linsert $attr(style) 0 "n"]
  230. }
  231.  
  232. proc help::tag_/nobr {params} {
  233.  variable attr
  234.  
  235.  if {[set pos [lsearch $attr(style) "n"]]!=-1} {
  236.   set attr(style) [lreplace $attr(style) $pos $pos]
  237.  }
  238. }
  239.  
  240. proc help::tag_hr {params} {
  241.  variable attr
  242.  variable w
  243.  variable _text
  244.  
  245.  if {[$w.text get "end -2c"]!="\n"} {
  246.   $w.text insert end "\n" [gettags]
  247.  }
  248.  set p_height ""
  249.  set p_color ""
  250.  foreach {param value} $params {
  251.   set p_$param $value
  252.  }
  253.  eval "$w.text insert end [gethr $p_height $p_color]"
  254.  if {[string index $_text 0]=="\n"} {
  255.   set _text [string range $_text 1 end]
  256.  }
  257. }
  258.  
  259. proc help::tag_br {params} {
  260.  variable w
  261.  $w.text insert end "\n" [gettags]
  262. }
  263.  
  264. proc help::tag_ul {params} {
  265.  variable w
  266.  variable attr
  267.  
  268.  set attr(justify) ""
  269.  set p_type "disc"
  270.  set p_indent 48
  271.  foreach {param value} $params {
  272.   set p_$param $value
  273.  }
  274.  incr attr(margin) $p_indent
  275.  set attr(ul_type) [linsert $attr(ul_type) 0 $p_type]
  276.  set attr(indent) [linsert $attr(indent) 0 $p_indent]
  277. # if {[$w.text get "end -3c"]!="\n"} {
  278. #  $w.text insert end "\n" [gettags]
  279. # }
  280.  if {[$w.text get "end -3c"]!="\n"} {
  281.   $w.text insert end "\n" [gettags]
  282.  }
  283. }
  284.  
  285. proc help::tag_/ul {params} {
  286.  variable w
  287.  variable attr
  288.  variable lmargin
  289.  variable tables
  290.  
  291.  catch {incr attr(margin) [expr {-[lindex $attr(indent) 0]}]}
  292.  if {$attr(margin)<$lmargin && $tables(stack)==""} {set attr(margin) $lmargin}
  293.  if {[$w.text get "end-3c"]!="\n"} {
  294.   $w.text insert end "\n" [gettags]
  295.  }
  296.  catch {set attr(indent) [lreplace $attr(indent) 0 0]}
  297.  catch {set attr(ul_type) [lreplace $attr(ul_type) 0 0]}
  298. }
  299.  
  300. proc help::tag_li {params} {
  301.  variable w
  302.  variable attr
  303.  variable data
  304.  variable _text
  305.  variable _count
  306.  variable _images
  307.  variable rmargin
  308.  
  309.  if {[$w.text get "end -2c"]!="\n"} {
  310.   $w.text insert end "\n" [gettags]
  311.  }
  312.  set p_type [lindex $attr(ul_type) 0]
  313.  foreach {param value} $params {
  314.   set p_$param $value
  315.  }
  316.  if {![info exists _images($p_type)]} {
  317.   if {[info exists data($p_type,image)]} {
  318.    set im $data($p_type,image)
  319.   } else {
  320.    set im $_images(disc)
  321.   }
  322.  } else {
  323.   set im $_images($p_type)
  324.  }
  325.  catch {set imind [$w.text image create end -image $im -align center -padx 3]}
  326.  catch {$w.text tag add [gettags] $imind}
  327.  catch {$w.text tag configure tag[incr _count] -lmargin1 [expr $attr(margin) - 22] -rmargin $rmargin}
  328.  catch {$w.text tag add tag$_count $imind}
  329.  set _text [string trimleft $_text " \t\n"]
  330. }
  331.  
  332. proc help::tag_p {params} {
  333.  variable w
  334.  variable attr
  335.  
  336.  if {[$w.text get "end -3c"]!="\n"} {
  337.   $w.text insert end "\n" [gettags]
  338.  }
  339.  if {[$w.text get "end -3c"]!="\n"} {
  340.   $w.text insert end "\n" [gettags]
  341.  }
  342.  set p_align ""
  343.  foreach {param value} $params {
  344.   set p_$param $value
  345.  }
  346.  
  347.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  348.  set attr(justify) $p_align
  349. }
  350.  
  351. proc help::tag_/p {params} {
  352.  variable attr
  353.  
  354.  set attr(justify) ""
  355. }
  356.  
  357. proc help::tag_a {params} {
  358.  variable w
  359.  variable attr
  360.  upvar mark mark
  361.  
  362.  set p_name ""
  363.  set p_href ""
  364.  set p_title ""
  365.  foreach {param value} $params {
  366.   set p_$param $value
  367.  }
  368. #sch p_href bearbeiten
  369. # if p_href is a external reference (http: file: mailto: usw.), then ignore
  370.  if {[string first ":" $p_href]>=0} {
  371.   switch -glob -- [string tolower $p_href] {
  372.    file://* {set p_href [string range $p_href 7 end]}
  373.    tcl:* {set p_href "tcl:[string range $p_href 4 end]"}
  374.    tclscript:* {set p_href "tclscript:[string range $p_href 10 end]"}
  375.    default {set p_title $p_href
  376.             set p_href "tcl:help::showurl {$p_href}"
  377.            }
  378.   }
  379.  }
  380.  if {$p_href!="" && ![regexp "^tcl(script)?:" $p_href]} {
  381.   set p_href_neu [string tolower $p_href]
  382.   variable curtopic
  383.   set filename ""
  384.   if {[set pos [string first "?" $curtopic]]!=-1} {
  385.    set filename [string tolower [string range $curtopic 0 [expr $pos - 1]]]
  386.    if {[string first "#" $p_href_neu]==0} {
  387.     set p_href_neu $filename?[string range $p_href_neu 1 end]
  388.    } elseif {[set pos [string first "#" $p_href_neu]]>0} {
  389.     set p_href_neu [string replace $p_href_neu $pos $pos "?"]
  390.    } 
  391.   }
  392.   variable index
  393.   if {[lsearch $index $p_href_neu]>=0} {
  394.    set p_href $p_href_neu
  395.   } else {
  396.    if {[string first "#" $p_href]==0} {
  397.     set p_href $curtopic$p_href
  398.    } else {
  399.    }
  400.   }
  401.  }
  402. #/sch
  403.  set attr(links) [linsert $attr(links) 0 $p_href]
  404.  
  405.  if {$p_name!=""} {
  406.   set p_name [string tolower $p_name]
  407.   $w.text mark set "mark_$p_name" [$w.text index end-1c]
  408.   $w.text mark gravity "mark_$p_name" left
  409.   if {$p_name==$mark} {
  410.    after 200 "catch {$w.text yview \"mark_$p_name\"}; catch {$w.text see \"mark_$p_name\"}"
  411.   }
  412.  }
  413.  
  414.  set attr(link_titles) [linsert $attr(link_titles) 0 $p_title]
  415. }
  416.  
  417. proc help::tag_/a {params} {
  418.  variable attr
  419.  
  420.  catch {set attr(links) [lreplace $attr(links) 0 0]}
  421.  catch {set attr(link_titles) [lreplace $attr(link_titles) 0 0]}
  422. }
  423.  
  424. proc help::tag_font {params} {
  425.  variable attr
  426.  variable fontsize
  427.  
  428.  set tag_font ""
  429.  set p_color ""
  430.  set p_bgcolor ""
  431.  set p_size ""
  432.  set p_face ""
  433.  set {p_point-size} ""
  434.  foreach {param value} $params {
  435.   set p_$param $value
  436.  }
  437.  if {$p_color!=""} {
  438.   set attr(colors) [linsert $attr(colors) 0 [correctcolor [string tolower $p_color]]]
  439.   lappend tag_font "colors"
  440.  }
  441.  if {$p_bgcolor!=""} {
  442.   set attr(bgcolors) [linsert $attr(bgcolors) 0 [correctcolor [string tolower $p_bgcolor]]]
  443.   lappend tag_font "bgcolors"
  444.  }
  445.  if {$p_size!=""} {
  446.   if {[set sign [string index $p_size 0]]=="+" || $sign=="-" || ($p_size=="0" && [set sign "+"]=="+")} {
  447.    set attr(sizes) [linsert $attr(sizes) 0 "$sign[expr {abs($p_size) * 2}]"]
  448.   } else {
  449.    set attr(sizes) [linsert $attr(sizes) 0 [expr {$p_size * 2 + $fontsize - 6}]]
  450.   }
  451.   lappend tag_font "sizes"
  452.  }
  453.  if {${p_point-size}!=""} {
  454.   set attr(sizes) [linsert $attr(sizes) 0 ${p_point-size}]
  455.   lappend tag_font "sizes"
  456.  }
  457.  if {$p_face!=""} {
  458.   set attr(face) [linsert $attr(face) 0 $p_face]
  459.   lappend tag_font "face"
  460.  }
  461.  set attr(tag_fonts) [linsert $attr(tag_fonts) 0 $tag_font]
  462. }
  463.  
  464. proc help::tag_/font {params} {
  465.  variable attr
  466.  
  467.  foreach t [lindex $attr(tag_fonts) 0] {
  468.   catch {set attr($t) [lreplace $attr($t) 0 0]}
  469.  }
  470.  catch {set attr(tag_fonts) [lreplace $attr(tag_fonts) 0 0]}
  471. }
  472.  
  473. proc help::tag_img {params} {
  474.  variable w
  475.  variable attr
  476.  variable data
  477.  variable curfilename
  478.  variable _images
  479.  
  480.  set p_src ""
  481.  set p_align ""
  482.  set p_border ""
  483.  set p_id ""
  484.  foreach {param value} $params {
  485.   set p_$param $value
  486.  }
  487.  if {[info exists data($p_src,image)]} {
  488.   catch {set imind [$w.text image create end -image $data($p_src,image)]}
  489.  } else {
  490. #sch i think you mean [catch {...}] == 0
  491. #angra No, i mean that i mean: if i can't load image, the default image is drawing
  492.  if {[catch {set data($p_src,image) [image create photo -file [file join [file dirname $curfilename] $p_src]]}]} {
  493. #/sch
  494.    catch {set imind [$w.text image create end -image $_images(broken)]}
  495.  } else {
  496.    catch {set imind [$w.text image create end -image $data($p_src,image)]}
  497.   }
  498.  }
  499.  if {[set p_align [string tolower $p_align]]=="middle"} {
  500.   set p_align "center"
  501.  }
  502.  catch {$w.text image configure $imind -align [string tolower $p_align]}
  503.  catch {$w.text image configure $imind -padx $p_border -pady $p_border}
  504.  catch {$w.text tag add [gettags] $imind}
  505.  if {$p_id!=""} {
  506.   set data($p_id,image,id) $imind
  507.   set data($p_id,image,widget) $w
  508.  }
  509. }
  510.  
  511. proc help::tag_tt {params} {
  512.  variable attr
  513.  
  514.  set attr(style) [linsert $attr(style) 0 "t"]
  515. }
  516.  
  517. proc help::tag_/tt {params} {
  518.  variable attr
  519.  
  520.  if {[set pos [lsearch $attr(style) "t"]]!=-1} {
  521.   set attr(style) [lreplace $attr(style) $pos $pos]
  522.  }
  523. }
  524.  
  525. proc help::tag_ol {params} {
  526.  tag_ul $params
  527. }
  528.  
  529. proc help::tag_/ol {params} {
  530.  tag_/ul $params
  531. }
  532.  
  533. proc help::tag_em {params} {
  534.  tag_i $params
  535. }
  536.  
  537. proc help::tag_/em {params} {
  538.  tag_/i $params
  539. }
  540.  
  541. proc help::tag_strong {params} {
  542.  tag_b $params
  543. }
  544.  
  545. proc help::tag_/strong {params} {
  546.  tag_/b $params
  547. }
  548.  
  549. proc help::tag_code {params} {
  550.  tag_tt {}
  551.  tag_font {size +0}
  552. }
  553.  
  554. proc help::tag_/code {params} {
  555.  tag_/font {}
  556.  tag_/tt {}
  557. }
  558.  
  559. proc help::tag_samp {params} {
  560.  tag_code {}
  561. }
  562.  
  563. proc help::tag_/samp {params} {
  564.  tag_/code {}
  565. }
  566.  
  567. proc help::tag_kbd {params} {
  568.  variable attr
  569.  
  570.  set attr(style) [linsert $attr(style) 0 "k"]
  571. }
  572.  
  573. proc help::tag_/kbd {params} {
  574.  variable attr
  575.  
  576.  if {[set pos [lsearch $attr(style) "k"]]!=-1} {
  577.   set attr(style) [lreplace $attr(style) $pos $pos]
  578.  }
  579. }
  580.  
  581. proc help::tag_cite {params} {
  582.  tag_i $params
  583. }
  584.  
  585. proc help::tag_/cite {params} {
  586.  tag_/i $params
  587. }
  588.  
  589. proc help::tag_var {params} {
  590.  tag_i $params
  591. }
  592.  
  593. proc help::tag_/var {params} {
  594.  tag_/i $params
  595. }
  596.  
  597. proc help::tag_address {params} {
  598.  tag_i $params
  599. }
  600.  
  601. proc help::tag_/address {params} {
  602.  tag_/i $params
  603. }
  604.  
  605. proc help::tag_h1 {params} {
  606.  variable w
  607.  variable attr
  608.  variable fontsize
  609.  
  610.  set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 10}]]    ;#22
  611.  set attr(style) [linsert $attr(style) 0 "b"]
  612. #sch
  613.  if {[$w.text get "end -3c"]!="\n"} {
  614.   $w.text insert end "\n" [gettags]
  615.  }
  616.  if {[$w.text get "end -3c"]!="\n"} {
  617.   $w.text insert end "\n" [gettags]
  618.  }
  619.  set p_align ""
  620.  foreach {param value} $params {
  621.   set p_$param $value
  622.  }
  623.  
  624.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  625.  set attr(justify) $p_align
  626. #/sch
  627. }
  628.  
  629. proc help::tag_/h1 {params} {
  630.  variable w
  631.  variable attr
  632.  
  633.  if {[set pos [lsearch $attr(style) "b"]]!=-1} {
  634.   set attr(style) [lreplace $attr(style) $pos $pos]
  635.  }
  636.  catch {set attr(sizes) [lreplace $attr(sizes) 0 0]}
  637.  if {[$w.text get "end -2c"]!="\n"} {
  638.   $w.text insert end "\n" [gettags]
  639.  }
  640. #sch
  641.  set attr(justify) ""
  642. #/sch
  643. }
  644.  
  645. proc help::tag_h2 {params} {
  646.  variable w
  647.  variable attr
  648.  variable fontsize
  649.  
  650.  set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 6}]]  ;#18
  651.  set attr(style) [linsert $attr(style) 0 "b"]
  652. #sch
  653.  if {[$w.text get "end -3c"]!="\n"} {
  654.   $w.text insert end "\n" [gettags]
  655.  }
  656.  if {[$w.text get "end -3c"]!="\n"} {
  657.   $w.text insert end "\n" [gettags]
  658.  }
  659.  set p_align ""
  660.  foreach {param value} $params {
  661.   set p_$param $value
  662.  }
  663.  
  664.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  665.  set attr(justify) $p_align
  666. #/sch
  667. }
  668.  
  669. proc help::tag_/h2 {params} {
  670.  tag_/h1 $params
  671. }
  672.  
  673. proc help::tag_h3 {params} {
  674.  variable w
  675.  variable attr
  676.  variable fontsize
  677.  
  678.  set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 2}]]  ;#14
  679.  set attr(style) [linsert $attr(style) 0 "b"]
  680. #sch
  681.  if {[$w.text get "end -3c"]!="\n"} {
  682.   $w.text insert end "\n" [gettags]
  683.  }
  684.  if {[$w.text get "end -3c"]!="\n"} {
  685.   $w.text insert end "\n" [gettags]
  686.  }
  687.  set p_align ""
  688.  foreach {param value} $params {
  689.   set p_$param $value
  690.  }
  691.  
  692.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  693.  set attr(justify) $p_align
  694. #/sch
  695. }
  696.  
  697. proc help::tag_/h3 {params} {
  698.  tag_/h1 $params
  699. }
  700.  
  701. proc help::tag_h4 {params} {
  702.  variable w
  703.  variable attr
  704.  variable fontsize
  705.  
  706.  set attr(sizes) [linsert $attr(sizes) 0 $fontsize]  ;#12
  707.  set attr(style) [linsert $attr(style) 0 "b"]
  708. #sch
  709.  if {[$w.text get "end -3c"]!="\n"} {
  710.   $w.text insert end "\n" [gettags]
  711.  }
  712.  if {[$w.text get "end -3c"]!="\n"} {
  713.   $w.text insert end "\n" [gettags]
  714.  }
  715.  set p_align ""
  716.  foreach {param value} $params {
  717.   set p_$param $value
  718.  }
  719.  
  720.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  721.  set attr(justify) $p_align
  722. #/sch
  723. }
  724.  
  725. proc help::tag_/h4 {params} {
  726.  tag_/h1 $params
  727. }
  728.  
  729. proc help::tag_h5 {params} {
  730.  variable w
  731.  variable attr
  732.  variable fontsize
  733.  
  734.  set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize - 2}]]  ;#10
  735.  set attr(style) [linsert $attr(style) 0 "b"]
  736. #sch
  737.  if {[$w.text get "end -3c"]!="\n"} {
  738.   $w.text insert end "\n" [gettags]
  739.  }
  740.  if {[$w.text get "end -3c"]!="\n"} {
  741.   $w.text insert end "\n" [gettags]
  742.  }
  743.  set p_align ""
  744.  foreach {param value} $params {
  745.   set p_$param $value
  746.  }
  747.  
  748.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  749.  set attr(justify) $p_align
  750. #/sch
  751. }
  752.  
  753. proc help::tag_/h5 {params} {
  754.  tag_/h1 $params
  755. }
  756.  
  757. proc help::tag_h6 {params} {
  758.  variable w
  759.  variable attr
  760.  variable fontsize
  761.  
  762.  set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize - 4}]]  ;#8
  763.  set attr(style) [linsert $attr(style) 0 "b"]
  764. #sch
  765.  if {[$w.text get "end -3c"]!="\n"} {
  766.   $w.text insert end "\n" [gettags]
  767.  }
  768.  if {[$w.text get "end -3c"]!="\n"} {
  769.   $w.text insert end "\n" [gettags]
  770.  }
  771.  set p_align ""
  772.  foreach {param value} $params {
  773.   set p_$param $value
  774.  }
  775.  
  776.  if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
  777.  set attr(justify) $p_align
  778. #/sch
  779. }
  780.  
  781. proc help::tag_/h6 {params} {
  782.  tag_/h1 $params
  783. }
  784.  
  785. proc help::tag_blockquote {params} {
  786.  tag_ul {}
  787. }
  788.  
  789. proc help::tag_/blockquote {params} {
  790.  tag_/ul {}
  791. }
  792.  
  793. proc help::tag_menu {params} {
  794.  tag_ul {}
  795. }
  796.  
  797. proc help::tag_/menu {params} {
  798.  tag_/ul {}
  799. }
  800.  
  801. proc help::tag_dir {params} {
  802.  tag_ul {}
  803. }
  804.  
  805. proc help::tag_/dir {params} {
  806.  tag_/ul {}
  807. }
  808.  
  809. proc help::tag_div {params} {
  810.  tag_p $params
  811. }
  812.  
  813. proc help::tag_/div {params} {
  814.  tag_/p $params
  815. }
  816.  
  817. proc help::tag_body {params} {
  818.  variable w
  819.  variable settings
  820.  variable _t_title
  821.  
  822.  tag_/head {}
  823.  foreach {v1 v2} {text fore bgcolor back link link alink alink} {
  824.   set p_$v1 $settings($v2)
  825.  }
  826.  foreach {param value} $params {
  827.   set p_$param $value
  828.  }
  829.  foreach {v1 v2} {text fore bgcolor back link link alink alink} {
  830.   set settings($v2) [correctcolor [string tolower [set p_$v1]]]
  831.  }
  832.  catch {$w.text configure -foreground $settings(fore)}
  833.  catch {$w.text configure -background $settings(back)}
  834.  catch {$w.title configure -foreground $settings(fore)}
  835.  catch {$w.title configure -background $settings(back)}
  836.  foreach {name} {title line __index contents __next __prev __Next __Prev __up1level 
  837.                  __dec __find __inc __open __refresh __reload __stop __search} {
  838.   catch {
  839.    if {[$w.title bind $_t_title($name) <1>]==""} {
  840.     catch {$w.title itemconfigure $_t_title($name) -fill $settings(fore)}
  841.    } else {
  842.     catch {$w.title itemconfigure $_t_title($name) -fill $settings(link)}
  843.    }
  844.   }
  845.  }
  846. }
  847.  
  848. proc help::tag_title {params} {
  849.  variable _istitle 1
  850. }
  851.  
  852. proc help::tag_/title {params} {
  853.  variable w
  854.  variable _istitle 0
  855.  variable _t_title
  856.  variable data
  857.  
  858.  if {[info exists data(title)] && $data(title)!=""} {
  859.   regsub -all -- "\[\r\n \]+" $data(title) " " data(title)
  860.  } else {
  861.   set data(title) "Untitled"
  862.  }
  863.  
  864.  if {[string match {.tophelpwindow*} $w]} {
  865.   wm title .tophelpwindow "Help - [specialentities $data(title)]"
  866.  }
  867.  $w.title itemconfigure $_t_title(title) -text [specialentities $data(title)]
  868. }
  869.  
  870. proc help::tag_/head {params} {
  871.  variable _istitle
  872.  
  873.  if {$_istitle} {
  874.   tag_/title {}
  875.  }
  876. }
  877.  
  878. proc help::tag_/tr {params} {
  879.  variable w
  880.  
  881.  if {[$w.text get "end -2c"]!="\n"} {
  882.   $w.text insert end "\n" [gettags]
  883.  }
  884. }
  885.  
  886. proc help::tag_/td {params} {
  887.  variable w
  888.  
  889.  if {[$w.text get "end -2c"]!=" "} {
  890.   $w.text insert end " " [gettags]
  891.  }
  892. }
  893.  
  894. proc help::tag_table {params} {
  895.  variable w
  896.  variable attr
  897.  
  898.  if {[$w.text get "end -2c"]!="\n"} {
  899.   $w.text insert end "\n" [gettags]
  900.  }
  901.  
  902.  set p_bgcolor ""
  903.  foreach {param value} $params {
  904.   set p_$param $value
  905.  }
  906.  if {$p_bgcolor!=""} {
  907.   set attr(bgcolors) [linsert $attr(bgcolors) 0 [correctcolor [string tolower $p_bgcolor]]]
  908.   set attr(tables) [linsert $attr(tables) 0 "bg"]
  909.  }
  910. }
  911.  
  912. proc help::tag_/table {params} {
  913.  variable w
  914.  variable attr
  915.  
  916.  if {[$w.text get "end -2c"]!="\n"} {
  917.   $w.text insert end "\n" [gettags]
  918.  }
  919.  if {[set pos [lsearch $attr(tables) "bg"]]!=-1} {
  920.   set attr(tables) [lreplace $attr(tables) $pos $pos]
  921.   catch {set attr(bgcolors) [lreplace $attr(bgcolors) 0 0]}
  922.  }
  923. }
  924.  
  925. proc help::tag_dd {params} {
  926.  variable w
  927.  variable _need_tag
  928.  
  929.  if {[set pos [lsearch $_need_tag "/dt"]]!=-1} {
  930.   tag_/dt {}
  931.  }
  932.  if {[$w.text get "end -2c"]!="\n"} {
  933.   $w.text insert "end -1c" "\n" [gettags]
  934.  }
  935.  set _need_tag [linsert $_need_tag 0 "/dd"]
  936. }
  937.  
  938. proc help::tag_/dd {params} {
  939.  variable _need_tag
  940.  
  941.  if {[set pos [lsearch $_need_tag "/dd"]]!=-1} {
  942.   set _need_tag [lreplace $_need_tag $pos $pos]
  943.  }
  944. }
  945.  
  946. proc help::tag_dl {params} {
  947.  tag_ul {}
  948. }
  949.  
  950. proc help::tag_/dl {params} {
  951.  tag_/ul {}
  952. }
  953.  
  954. proc help::tag_dt {params} {
  955.  variable w
  956.  variable _need_tag
  957.  
  958.  if {[set pos [lsearch $_need_tag "/dt"]]!=0} {
  959.   set _need_tag [linsert $_need_tag 0 "/dt"]
  960.   tag_/ul {}
  961.  } else {
  962.   if {[$w.text get "end -2c"]!="\n"} {
  963.    $w.text insert "end -1c" "\n" [gettags]
  964.   }
  965.  }
  966. }
  967.  
  968. proc help::tag_/dt {params} {
  969.  variable _need_tag
  970.  
  971.  if {[set pos [lsearch $_need_tag "/dt"]]!=-1} {
  972.   set _need_tag [lreplace $_need_tag $pos $pos]
  973.  }
  974.  tag_ul {}
  975. }
  976.  
  977. proc help::tag_frame {params} {
  978.  variable w
  979.  
  980.  set p_name ""
  981.  set p_src ""
  982.  foreach {param value} $params {
  983.   set p_$param $value
  984.  }
  985.  if {$p_name==""} {
  986.   set p_name $p_src
  987.  }
  988.  if {$p_src!=""} {
  989.   if {[$w.text get "end -2c"]!="\n"} {
  990.    $w.text insert end "\n" [gettags]
  991.   }
  992.   $w.text insert end "Frame " [gettags]
  993.   tag_a [list href $p_src]
  994.   $w.text insert end "$p_name" [gettags]
  995.   tag_/a {}
  996.   tag_br {}
  997.  }
  998. }
  999.  
  1000. proc help::tag_script {params} {
  1001.  variable _isscript
  1002.  variable _istext
  1003.  variable data
  1004.  
  1005.  set p_language ""
  1006.  foreach {param value} $params {
  1007.   set p_$param $value
  1008.  }
  1009.  if {[string tolower $p_language]=="tclscript"} {
  1010.   set _isscript 1
  1011.   set data(script) ""
  1012.  } else {
  1013.   set _istext 0
  1014.  }
  1015. }
  1016.  
  1017. proc help::tag_/script {params} {
  1018.  variable data
  1019.  variable interp
  1020.  variable _isscript
  1021.  variable _istext
  1022.  
  1023.  if {$_isscript && $data(script)!=""} {
  1024.   if {[catch {$interp eval $data(script)}]} {
  1025.    set data(__@Error@__,title) "Error in loaded script"
  1026.    set data(__@Error@__,text) "<font color=red><pre>[string map {{&} {&} {>} {>} {<} {<}} $::errorInfo]</pre></font>"
  1027.    set _isscript 0
  1028.    show __@Error@__  
  1029.   }
  1030.  } elseif {!$_istext} {
  1031.   set _istext 1
  1032.  }
  1033.  set _isscript 0
  1034. }
  1035.  
  1036. proc help::tag_style {params} {
  1037.  variable _istext 0
  1038. }
  1039.  
  1040. proc help::tag_/style {params} {
  1041.  variable _istext 1
  1042. }
  1043.  
  1044. proc help::tag_span {params} {
  1045.  variable w
  1046.  variable attr
  1047.  variable data
  1048.  variable _count
  1049.  
  1050.  set p_id ""
  1051.  set p_hidden 0
  1052.  foreach {param value} $params {
  1053.   set p_$param $value
  1054.  }
  1055.  if {$p_id!=""} {
  1056.   incr _count
  1057.   set data($p_id,names,id) "tag$_count"
  1058.   set data($p_id,names,widget) $w
  1059.   set data($p_id,names,pos) [$w.text index "end-1c"]
  1060.   if {$p_hidden==""} {set p_hidden 1}
  1061.   catch {$w.text tag configure "tag$_count" -elide $p_hidden}
  1062.  }
  1063.  set attr(span) [linsert $attr(span) 0 $p_id]
  1064. }
  1065.  
  1066. proc help::tag_/span {params} {
  1067.  variable attr
  1068.  variable data
  1069.  
  1070.  if {[set p_id [lindex $attr(span) 0]]!=""} {
  1071.   catch {$data($p_id,names,widget).text tag add $data($p_id,names,id) $data($p_id,names,pos) "end-1c"}
  1072.  }
  1073.  set attr(span) [lreplace $attr(span) 0 0]
  1074. }
  1075.  
  1076. #===============================================================================
  1077.  
  1078. #-------------------------------------------------------------------------------
  1079. # Function       :  help::correctcolor
  1080. # Description    :  Converts color names to color values
  1081. # Parameters     :  color       - name of color
  1082. # Return         :  Color value
  1083. #-------------------------------------------------------------------------------
  1084. proc help::correctcolor {color} {
  1085.  return [string map {\
  1086.    green   "#008000" silver "#c0c0c0" lime   "#00ff00" gray "#808080" \
  1087.    olive   "#808000" navy   "#000080" purple "#800080" teal "#008080" \
  1088.    fuchsia "#ff00ff" aqua   "#00ffff" maroon "#800000"
  1089.  } $color]
  1090. }
  1091.  
  1092. #-------------------------------------------------------------------------------
  1093. # Function       :  help::_load
  1094. # Description    :  Load helpfile with includes
  1095. # Parameters     :  filename    - name of file with help
  1096. # Return         :  True or false
  1097. #-------------------------------------------------------------------------------
  1098. proc help::_load {filename} {
  1099.  variable stat
  1100.  variable data
  1101.  variable index 
  1102.  variable font 
  1103.  variable fontfixed 
  1104.  variable fontsize 
  1105.  variable backcolor 
  1106.  variable forecolor 
  1107.  variable linkcolor 
  1108.  variable alinkcolor
  1109.  variable lmargin
  1110.  variable rmargin
  1111.  variable curfilename
  1112. #sch
  1113.  variable hcontents
  1114.  variable h2ignore 
  1115.  variable h4topics
  1116.  variable h4contents
  1117.  set schAnkerNr 0
  1118.  set headerstr ""
  1119.  set headerlevel ""
  1120.  set headertxt ""
  1121.  set topicname ""
  1122.  set topictitle ""
  1123. #/sch
  1124.  variable h_appendlist
  1125.  variable searchedtext ""
  1126.  variable controls
  1127.  variable buttons
  1128.  
  1129.  set stat "Loading $filename..."
  1130.  update
  1131.  if {[catch {set fname [::open $filename r]}]!=0} {
  1132.   append data(__file_error,text)  "<p><font color=#c00000>Error while opening file:</font> <b>\"$filename\"</b><font color=#c00000>!</font></p>"
  1133.   set data(__file_error,title) "Error!"
  1134.   if {![info exists index] || [lsearch $index "__file_error"]==-1} {
  1135.    lappend index __file_error
  1136.   }
  1137.   return 0
  1138.  }
  1139.  set curtopic ""
  1140.  set filedata ""
  1141.  while {![eof $fname]} {
  1142.   append filedata [read $fname 100000]
  1143.  }
  1144.  ::close $fname
  1145.  if {$h4topics!="" || $h4contents!=""} {
  1146.   regsub -all -- {<!--.*?-->} $filedata "" filedata
  1147.  }
  1148.  set filedata [split $filedata "\n"]
  1149.  foreach str $filedata {
  1150. #sch test section headings and create topics, fill hcontents
  1151.   append headerstr $str
  1152.   if {![regexp -nocase {<h[1-6][^>]*>} $headerstr]} {
  1153.    set headerstr ""
  1154.   } elseif {[regexp -nocase \
  1155.   {<h([1-6])[^>]*>(.*?)</h[1-6]>} $headerstr Dummy headerlevel headertxt]} {
  1156.  
  1157.    if {$h2ignore!="" && [regexp -nocase $h2ignore $headerstr]} {
  1158.     set str $headerstr
  1159.     set headerstr ""
  1160. #    continue
  1161.    } else {
  1162.     if {$h4topics!="" && [regexp -nocase -- $h4topics $headerstr]} {
  1163.      regsub -all -nocase -- {<br>} $headertxt { } headertxt
  1164.      regsub -all -- {<[^>]*>} $headertxt {} topictitle
  1165.      if {![regexp -nocase {^.*<a +.*? *name *= *(" *([^\"]+) *"|([^\"]([^ >]*)))} \
  1166.      $headertxt Dummy topicname]} {
  1167.       set topicname internal_[incr schAnkerNr]
  1168.      }
  1169.      set curtopic [string tolower [file tail $filename]?[string trim $topicname "\t\" "]]
  1170.      lappend index $curtopic
  1171.      set data($curtopic,text) ""
  1172.      set data($curtopic,title) [string trim [specialentities $topictitle] "\t\" "]
  1173.     } else {
  1174.      set topicname ""
  1175.     }
  1176.   
  1177.     if {$h4contents!="" && [regexp -nocase -- $h4contents $headerstr]} {
  1178.      regsub -all -nocase -- {<br>} $headertxt { } headertxt
  1179.      regsub -all -- {<[^>]*>} $headertxt {} topictitle
  1180.      if {$topicname!=""} {
  1181.       lappend hcontents [list $headertxt $headerlevel [string trim $topictitle] $curtopic]
  1182.      } else {
  1183.       lappend hcontents [list $headertxt $headerlevel [string trim $topictitle] ""]
  1184.      }
  1185.     }
  1186.     set str $headerstr 
  1187.     set headerstr ""
  1188.    }
  1189.   } else {
  1190.    continue
  1191.   }
  1192. #/sch
  1193.  
  1194. #sch new control directives .h2ignore* .h4topics* .h4contents* added in switch
  1195. #/sch
  1196.   switch -glob -- $str {
  1197.    .h_ignore*   {set h2ignore [string trim [string range $str 9 end] "\t\" "]}
  1198.    .h_topics*   {set h4topics [string trim [string range $str 9 end] "\t\" "]}
  1199.    .h_contents* {set h4contents [string trim [string range $str 11 end] "\t\" "]}
  1200.    .h_appendlist* {set h_appendlist [regexp -- "(yes)|(1)|(true)" [string tolower [string trim [string range $str 11 end] "\t\" "]]]}
  1201.    .fontsize*   {catch {set fontsize [expr [string trim [string range $str 9 end] "\t\" "]]}}
  1202.    .fontfixed*  {set fontfixed [string trim [string range $str 10 end] "\t\" "]}
  1203.    .font*       {set font [string trim [string range $str 5 end] "\t\" "]}
  1204.    .forecolor*  {set forecolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
  1205.    .backcolor*  {set backcolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
  1206.    .linkcolor*  {set linkcolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
  1207.    .alinkcolor* {set alinkcolor [correctcolor [string tolower [string trim [string range $str 11 end] "\t\" "]]]}
  1208.    .lmargin*    {catch {set lmargin [expr [string trim [string range $str 8 end] "\t\" "]]}}
  1209.    .rmargin*    {catch {set rmargin [expr [string trim [string range $str 8 end] "\t\" "]]}}
  1210.    .topic*      {set curtopic [string trim [string range $str 6 end] "\t\" "]
  1211.                  if {$curtopic!=""} {
  1212.                   lappend index $curtopic
  1213.                   set data($curtopic,title) "$curtopic"
  1214.                   set data($curtopic,text) ""
  1215.                  }
  1216.                 }
  1217.    .title*      {if {$curtopic!=""} {
  1218.                   set data($curtopic,title) [string trim [string range $str 6 end] "\t\" "]
  1219.                  }
  1220.                 }
  1221.    .image*      {set str [split $str]
  1222.                  set imname ""
  1223.                  set imtype ""
  1224.                  set imdata ""
  1225.                  set i 1
  1226.                  for {} {$i<[llength $str]} {incr i} {
  1227.                   if {[lindex $str $i]!=""} {
  1228.                    set imname [string trim [lindex $str $i]]
  1229.                    incr i
  1230.                    break
  1231.                   }
  1232.                  }
  1233.                  for {} {$i<[llength $str]} {incr i} {
  1234.                   if {[lindex $str $i]!=""} {
  1235.                    set imtype [string trim [lindex $str $i]]
  1236.                    incr i
  1237.                    break
  1238.                   }
  1239.                  }
  1240.                  set imdata [string trim [join [lrange $str $i end]]]
  1241.                  switch -- $imtype {
  1242.                   file {catch {set data($imname,image) [image create photo -file [file join [file dirname $filename] $imdata]]}}
  1243.                   data {catch {set data($imname,image) [image create photo -data $imdata]}}
  1244.                  }
  1245.                 }
  1246.    .include*    {variable inclstr
  1247.                  set inclstr [string trim [join [lrange [split $str] 1 end]] "\t\" "]
  1248.                  catch "namespace eval :: {set [namespace current]::inclstr \"$inclstr\"}"
  1249.                  _load [file join [file dirname $filename] $inclstr]
  1250.                 }
  1251.    .$*          {set str [split $str]
  1252.                  set substname ""
  1253.                  set substbegin ""
  1254.                  set substend ""
  1255.                  set i 1
  1256.                  for {} {$i<[llength $str]} {incr i} {
  1257.                   if {[lindex $str $i]!=""} {
  1258.                    set substname [string tolower [string trim [lindex $str $i]]]
  1259.                    incr i
  1260.                    break
  1261.                   }
  1262.                  }
  1263.                  set subst [string trim [join [lrange $str $i end]]]
  1264.                  catch {set substbegin [lindex $subst 0]}
  1265.                  catch {set substend   [lindex $subst 1]}
  1266.                  if {$substname!="" && ($substbegin!="" || $substend!="")} {
  1267.                   set data(subst,$substname,begin) $substbegin
  1268.                   set data(subst,$substname,end)   $substend
  1269.                  }
  1270.                 }
  1271.     .controls*  {
  1272.                  set controls [string tolower [string trim [string range $str 9 end] "\t\" "]]
  1273.                 } 
  1274.     .buttons*   {
  1275.                  set buttons [string tolower [string trim [string range $str 8 end] "\t\" "]]
  1276.                 } 
  1277.     default     {if {$curtopic!=""} {
  1278.                   if {[string index $str 0]!={;}} {
  1279.                    append data($curtopic,text) "$str\n"
  1280.                   }
  1281.                  } else {
  1282.                   append data(text) "$str\n"
  1283.                  }
  1284.                 }
  1285.   }
  1286.  }
  1287.  return 1
  1288. }
  1289.  
  1290.  
  1291. #-------------------------------------------------------------------------------
  1292. # Function       :  help::load
  1293. # Description    :  Load helpfile and make index
  1294. # Parameters     :  filename    - name of file with help
  1295. # Return         :  True or false
  1296. #-------------------------------------------------------------------------------
  1297. proc help::load {filename} {
  1298.  variable w
  1299.  variable stat
  1300.  variable data
  1301.  variable curfilename
  1302.  
  1303.  if {$filename==$curfilename} {
  1304.   return 1
  1305.  }
  1306.  
  1307.  variable settings
  1308.  variable history 
  1309.  variable index 
  1310.  variable hpos
  1311.  
  1312.  if {$index!=""} {
  1313.   set index ""
  1314.   set history ""
  1315.   set hpos 0
  1316.  }
  1317.  
  1318.  variable font "Helvetica"
  1319.  variable fontfixed "Courier"
  1320.  variable fontsize 12
  1321.  variable backcolor ""
  1322.  variable forecolor black
  1323.  variable linkcolor "#006800"
  1324.  variable alinkcolor "#c00000"
  1325.  variable lmargin 6
  1326.  variable rmargin 6
  1327.  variable curtopic ""
  1328.  variable attr
  1329. #sch declare vars
  1330.  variable up1level 
  1331.  variable sequence ""
  1332.  variable hcontents ""
  1333.  variable h2ignore ""
  1334.  variable h4topics ""
  1335.  variable h4contents ""
  1336. #/sch
  1337.  variable h_appendlist 1
  1338.  variable controls "back forw cont index search prev up next"
  1339.  variable buttons "back forw prev up next sep stop sep cont ind"
  1340.  
  1341.  array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
  1342.  
  1343.  foreach imn [array names data *,image] {
  1344.   catch {image delete $data($imn)}
  1345.  }
  1346.  catch {unset data}
  1347.  foreach btn "back cont dec find forward inc index next open prev refresh reload search stop up" {
  1348.   catch {grid forget $w.b$btn}
  1349.  }
  1350.  for {set i 0} {$i<50} {incr i} {grid columnconfig $w $i -minsize 0}
  1351.  if {![_load $filename]} {
  1352.   set curfilename ""
  1353.   set stat "Error while loading $filename!"
  1354.   buttons
  1355.   return 0
  1356.  }
  1357.  buttons
  1358.  set stat "Done."
  1359.  update
  1360.  
  1361. #sch create Topic Contents from hcontents and up1level for __up1level
  1362.  if {$hcontents!=""} {
  1363.   set data(contents,title) "Contents"
  1364.   set data(contents,text) "<ul>"
  1365.   set links(contents) ""
  1366.   # set topicname_prev ""
  1367.   set level(0) [list Contents 0 Contents contents]
  1368.   for {set i 1} {$i<=6} {incr i} {  
  1369.    set level($i) ""
  1370.   }
  1371.   foreach str $hcontents {
  1372.    #set headertxt [lindex $str 0]
  1373.    set headerlevel  [lindex $str 1]
  1374.    set topictitle  [lindex $str 2]
  1375.    set topicname  [lindex $str 3]
  1376.    set prefix [string repeat "    " [expr $headerlevel - 1]]
  1377.    set level($headerlevel) $str
  1378.    for {set i [expr $headerlevel + 1]} {$i<=6} {incr i} {   
  1379.     set level($i) ""
  1380.    }
  1381.    set links($topicname) ""
  1382.    if {$topicname!=""} {
  1383.     append data(contents,text) "$prefix<a href=\"$topicname\">$topictitle</a><br>"
  1384.    } else {
  1385.     append data(contents,text) "$prefix$topictitle<br>"
  1386.    }
  1387.    for {set i [expr $headerlevel - 1]} {$i>0&&$level($i)==""} {incr i -1} { 
  1388.    }
  1389.    set str_i $level($i)
  1390.    if {$str_i!=""} {
  1391.     #set headertxt_i [lindex $str_i 0]
  1392.     set headerlevel_i  [lindex $str_i 1]
  1393.     set topictitle_i  [lindex $str_i 2]
  1394.     set topicname_i [lindex $str_i 3]
  1395.     if {$topicname_i != ""} {
  1396.      set up1level($topicname) $topicname_i
  1397.      if {$topicname!=""} {
  1398.       append links($topicname_i) "<a href=\"$topicname\">$topictitle</a><br>"
  1399.      }
  1400.     }
  1401.    }
  1402.   }
  1403.   append data(contents,text) "</ul>"
  1404.   lappend index contents
  1405.   if {$h_appendlist} {
  1406.    set links(contents) ""
  1407.    foreach topicname_i [array names links] {
  1408.     if {$links($topicname_i)!=""} {
  1409.      append data($topicname_i,text) "<ul>" $links($topicname_i) "</ul>"
  1410.     }
  1411.    }
  1412.   }
  1413.  }
  1414. #/sch
  1415.  
  1416. #sch_05 create sequence for __Next, __up1level and __Prev
  1417.  if {[lsearch $index contents]>=0} {
  1418.   lappend sequence contents
  1419.  }
  1420.  foreach topicname $index {
  1421.   if {$topicname!="contents"} {
  1422.    lappend sequence $topicname
  1423.   }
  1424.  }
  1425.  lappend sequence __index
  1426. #/sch
  1427.  
  1428.  set data(title) ""
  1429.  if {$index!=""} {
  1430.   set iind ""
  1431.   foreach i $index {
  1432.    lappend iind [list $i $data($i,title)]
  1433.   }
  1434.   set iind [lsort -index 1 -dictionary $iind]
  1435.   set data(__index,title) "Index"
  1436.   set data(__index,text) "<br><ul>"
  1437.   foreach i $iind {
  1438.    set outtext [lindex $i 1]
  1439.    append data(__index,text) "<li><a href=\"[lindex $i 0]\">[string map {{&} {&} {>} {>} {<} {<}} $outtext]</a> <br>"
  1440.   }
  1441.   append data(__index,text) "</ul>"
  1442.   lappend index __index
  1443.  }
  1444.  catch {$w.text configure -font "-family $font -size $fontsize"}
  1445.  catch {$w.text configure -foreground $forecolor}
  1446.  catch {$w.text configure -background $backcolor}
  1447.  catch {$w.title configure -background [$w.text cget -background]}
  1448.  set curfilename $filename
  1449.  array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
  1450.  return 1
  1451. }
  1452.  
  1453. #-------------------------------------------------------------------------------
  1454. # Function       :  help::init
  1455. # Description    :  Create window, load file and show topic
  1456. # Parameters     :  filename    - name of file with help
  1457. #                :  topic       - topic name
  1458. #                :  parent      - parent widget
  1459. #                :  width       - initial width of help window
  1460. #                :  height      - initial height of help window
  1461. # Return         :  Nothing
  1462. #-------------------------------------------------------------------------------
  1463. #sch new parameters  {width 450} {height 400}
  1464. proc help::init {filename {topic contents} {parent {}} {width 450} {height 400} } {
  1465. #/sch
  1466.  variable w
  1467.  variable gw
  1468.  variable settings
  1469.  variable font
  1470.  variable fontsize
  1471.  variable history
  1472.  variable _images
  1473.  variable _dnum
  1474.  variable btninfo
  1475.  global   tcl_platform
  1476.  
  1477.  if {![info exists w] || ![winfo exists $w]} {
  1478.   set w $parent
  1479.   if {$parent==""} {
  1480.    set w ".tophelpwindow"
  1481. #sch 
  1482.    if {$width<450} {set width 450}
  1483.    if {$height<400} {set height 400}
  1484.    toplevel $w -width $width -height $height
  1485. #/sch
  1486.    wm title .tophelpwindow "Help"
  1487.    wm minsize .tophelpwindow 170 120
  1488.    raise .tophelpwindow
  1489.    focus -force .tophelpwindow
  1490.   }
  1491.  
  1492.   if {[wm protocol [winfo toplevel $w] WM_DELETE_WINDOW]==""} {
  1493.    wm protocol [winfo toplevel $w] WM_DELETE_WINDOW "help::destroy 1"
  1494.   }
  1495.  
  1496.   if {$w!="."} {append w "."}
  1497. #sch
  1498.   frame ${w}f -width $width -height $height -bd 2 -relief sunken
  1499. #/sch1
  1500.   pack ${w}f -fill both -expand 1
  1501.   append w "f"
  1502.   set gw $w
  1503.  
  1504.   canvas $w.title -bd 0 -highlightthickness 0 -cursor arrow -height 0 
  1505.   text $w.text -wrap none -cursor arrow -state disabled -bd 0 \
  1506.                -insertwidth 0 -insertontime 0 -exportselection 1\
  1507.                -highlightthickness 0 -takefocus 1 -insertborderwidth 0 \
  1508.                -yscrollcommand "$w.vs set" -xscrollcommand "$w.hs set"
  1509.   foreach elem {text title} {
  1510.    catch {$w.$elem configure -font "-family $font"}
  1511.    catch {$w.$elem configure -font "-size $fontsize"}
  1512.    catch {$w.$elem configure -foreground $settings(fore)}
  1513.    catch {$w.$elem configure -background $settings(back)}
  1514.   }
  1515.   scrollbar $w.vs -command "$w.text yview"
  1516.   scrollbar $w.hs -command "$w.text xview" -orient horizontal
  1517.  
  1518.   button $w.bback    -image $_images(back)    -width 15 -height 13 -command "help::show __prev" -state disabled
  1519.   button $w.bforward -image $_images(forward) -width 15 -height 13 -command "help::show __next" -state disabled
  1520.   button $w.bstop    -image $_images(stop)    -width 15 -height 13 -command "set help::abort 1" -state disabled
  1521.   button $w.brefresh -image $_images(refresh) -width 15 -height 13 -command "event generate $w.text <Control-r>"
  1522.  
  1523.   button $w.bdec     -image $_images(dec)    -width 15 -height 13 -command "event generate $w.text <Control-bracketleft>"
  1524.   button $w.binc     -image $_images(inc)    -width 15 -height 13 -command "event generate $w.text <Control-bracketright>"
  1525.   button $w.bcont    -image $_images(cont)   -width 15 -height 13 -command "help::show contents"
  1526.   button $w.bindex   -image $_images(index)  -width 15 -height 13 -command "help::show __index"
  1527.   button $w.bfind    -image $_images(find)   -width 15 -height 13 -command "help::dlgfind:init"
  1528.   button $w.bsearch  -image $_images(search) -width 15 -height 13 -command "help::dlgfind:init 0"
  1529.   button $w.breload  -image $_images(reload) -width 15 -height 13 -command "event generate $w.text <Control-l>"
  1530.   button $w.bopen    -image $_images(open)   -width 15 -height 13 -command "event generate $w.text <Control-o>"
  1531.   button $w.bprev    -image $_images(prev)   -width 15 -height 13 -command "help::show __Prev"
  1532.   button $w.bup      -image $_images(up)     -width 15 -height 13 -command "help::show __up1level"
  1533.   button $w.bnext    -image $_images(next)   -width 15 -height 13 -command "help::show __Next"
  1534.  
  1535.   foreach {name} {__index contents __next __prev __Next __Prev __up1level
  1536.                  __dec __find __inc __open __refresh __reload __stop __search} {
  1537.    foreach {txt vis expr btn} $btninfo($name) {
  1538.     bind $w.$btn <Enter> "set help::stat \{$txt\}"
  1539.     bind $w.$btn <Leave> "set help::stat \{Done.\}"
  1540.    }
  1541.   }
  1542.   
  1543.   label $w.stat -relief sunken -bd 1 -textvariable help::stat -justify left -anchor w
  1544.   label $w.d -image $_images(d[set _dnum]) -bd 0 -anchor se
  1545.   label $w.ugol -image $_images(ugol) -bd 0 -anchor se
  1546.  
  1547.   grid rowconfig    $w 0 -weight 1    -minsize 0
  1548.   grid rowconfig    $w 1 -weight 1000 -minsize 50
  1549. #  grid rowconfig    $w 3 -minsize 20
  1550.   grid columnconfig $w 50 -weight 1000 -minsize 50
  1551.  
  1552.   grid $w.title -padx 0 -pady 0 \
  1553.                -row 0 -column 0 -rowspan 1 -columnspan 52 -sticky new
  1554.   grid $w.text -padx 0 -pady 0 \
  1555.                -row 1 -column 0 -rowspan 1 -columnspan 51 -sticky news
  1556.   grid $w.vs   -padx 1 -pady 0 \
  1557.                -row 1 -column 51 -rowspan 1 -columnspan 1 -sticky news
  1558.   grid $w.hs   -padx 0 -pady 1 \
  1559.                -row 2 -column 0 -rowspan 1 -columnspan 51 -sticky news
  1560.   grid $w.d    -padx 0 -pady 0 \
  1561.                -row 2 -column 51 -rowspan 1 -columnspan 1 -sticky news
  1562.   grid $w.stat -padx 0 -pady 0 \
  1563.                -row 3 -column 50 -rowspan 1 -columnspan 1 -sticky nwes
  1564.   grid $w.ugol -padx 0 -pady 0 \
  1565.                -row 3 -column 51 -rowspan 1 -columnspan 1 -sticky es
  1566.  
  1567.   grid propagate $w 0
  1568.  
  1569.   focus $w.text
  1570.   $w.text tag configure h -font "-size 1" -spacing3 0
  1571.  
  1572.   bind $w.text <Key> "break"
  1573.   bind $w.text <KeyPress> "break"
  1574.   bind $w.text <KeyRelease> "break"
  1575.   bind $w.text <BackSpace> "help::show __prev;break"
  1576.   bind $w.text <Alt-F5> "help::show __prev;break"
  1577.   bind $w.text <Alt-Left> "help::show __prev;break"
  1578.   bind $w.text <Alt-Right> "help::show __next;break"
  1579.   bind $w.text <Double-1> "break"
  1580.   bind $w.text <1> "focus $w.text; $w.text tag remove fnd 1.0 end"
  1581.   bind $w.text <Escape> "set help::abort 1"
  1582.   bind $w.text <Control-R> "event generate $w.text <Control-r>"
  1583.   bind $w.text <Control-L> "event generate $w.text <Control-l>"
  1584.   bind $w.text <Control-bracketleft>  "if {\$help::fontsize>6} {incr help::fontsize -2; event generate $w.text <Control-r>}"
  1585.   bind $w.text <Control-bracketright> "if {\$help::fontsize<30} {incr help::fontsize 2; event generate $w.text <Control-r>}"
  1586.   bind $w.text <Control-c> "event generate $w.text <<Copy>>"
  1587.   bind $w.text <Control-C> "event generate $w.text <Control-c>"
  1588.   bind $w.text <Control-Insert> "event generate $w.text <Control-c>"
  1589.   bind $w.text <Control-o> "help::open"
  1590.   bind $w.text <Control-O> "event generate $w.text <Control-o>"
  1591.   bind $w.text <Right> "$w.text xview scroll +1 units; break"
  1592.   bind $w.text <Left>  "$w.text xview scroll -1 units; break"
  1593.   bind $w.text <Down>  "$w.text yview scroll +1 units; break"
  1594.   bind $w.text <Up>    "$w.text yview scroll -1 units; break"
  1595.   bind $w.text <Next>  "$w.text yview scroll +1 pages; break"
  1596.   bind $w.text <Prior> "$w.text yview scroll -1 pages; break"
  1597.   bind $w.text <Home>  "$w.text yview moveto 0; break"
  1598.   bind $w.text <End>   "$w.text yview moveto 1; break"
  1599.   bind $w.d    <Double-1> "help::show_about"
  1600.   bind $w.text <Control-f> "help::dlgfind:init; break"
  1601.   bind $w.text <Control-F> "event generate $w.text <Control-f>"
  1602.   bind $w.text <Control-s> "help::dlgfind:init 0; break"
  1603.   bind $w.text <Control-S> "event generate $w.text <Control-s>"
  1604.   bind $w.text <Control-Shift-f> "event generate $w.text <Control-s>"
  1605.   bind $w.text <Control-Shift-F> "event generate $w.text <Control-s>"
  1606.   if {$parent==""} {
  1607.    bind .tophelpwindow <FocusIn>  "help::focusin %W %m"
  1608.    bind .tophelpwindow <FocusOut> "help::focusout %W %m"
  1609.    bind .tophelpwindow <Configure> "help::focusin %W %m"
  1610.    bind .tophelpwindow <Destroy> "help::focusout %W %m"
  1611.    bind .tophelpwindow <Expose> "help::focusin %W %m"
  1612.   }
  1613.  
  1614.   menu $w.menu  -tearoff 0
  1615.   $w.menu add command -label "Back" -command "help::show __prev" -accelerator "<--"
  1616.   $w.menu add command -label "Forward" -command "help::show __next"
  1617.   $w.menu add command -label "Stop" -command "set help::abort 1" -accelerator "Esc"
  1618.   $w.menu add sep
  1619.   $w.menu add command -label "Copy" -command "event generate $w.text <Control-c>" -accelerator "Ctrl+Ins"
  1620.   $w.menu add sep
  1621.   $w.menu add command -label "Find..." -command "event generate $w.text <Control-f>" -accelerator "Ctrl+F"
  1622.   $w.menu add command -label "Search in topics..." -command "event generate $w.text <Control-Shift-f>" -accelerator "Ctrl+S"
  1623.   $w.menu add sep
  1624.   $w.menu add command -label "Open file..." -command "event generate $w.text <Control-o>" -accelerator "Ctrl+O"
  1625.   $w.menu add sep
  1626.   $w.menu add command -label "Increase font size" -command "event generate $w.text <Control-bracketright>" -accelerator "Ctrl+\]"
  1627.   $w.menu add command -label "Decrease font size" -command "event generate $w.text <Control-bracketleft>" -accelerator "Ctrl+\["
  1628.   $w.menu add sep
  1629.   $w.menu add command -label "Refresh" -command "event generate $w.text <Control-r>" -accelerator "Ctrl+R"
  1630.   $w.menu add command -label "Reload" -command "event generate $w.text <Control-l>" -accelerator "Ctrl+L"
  1631.   bind $w.text <3> "help::rightclick %X %Y"
  1632.  
  1633.   menu $w.menuX  -tearoff 0
  1634.   $w.menuX add command -label "About" -command "help::show_about"
  1635.   bind $w.d <3> "help::rightclickX %X %Y"
  1636.   help::userinit $w
  1637.  }
  1638.  
  1639.  if {[info exists w] && [winfo exists $w]} {
  1640.   raise [winfo toplevel $w]
  1641.   focus -force [winfo toplevel $w]
  1642.   focus -force $w.text
  1643.  }
  1644.  
  1645.  bind $w.text <Control-l> "set help::curtopic {}; set help::curfilename {}; help::init \{$filename\} \[lindex \[lindex \$help::history \$help::hpos\] 0\]"
  1646.  
  1647.  if {$filename==""} {
  1648.   help::open
  1649.   return
  1650.  }
  1651.  
  1652.  if {[load $filename]} {
  1653.   show $topic
  1654.  } else {
  1655.   show __file_error
  1656.  }
  1657. }
  1658.  
  1659. proc help::userinit {w} {
  1660. }
  1661.  
  1662. #-------------------------------------------------------------------------------
  1663. # Function       :  help::buttons
  1664. # Description    :  Place buttons 
  1665. # Parameters     :  None
  1666. # Return         :  Tagname
  1667. #-------------------------------------------------------------------------------
  1668. proc help::buttons {} {
  1669.  variable gw
  1670.  variable buttons
  1671.  variable h4contents
  1672.  
  1673.  set bcount -1
  1674.  foreach btn $buttons {
  1675.   switch -glob -- $btn {
  1676.    b*   {set btn "back"}
  1677.    c*   {set btn "cont"}
  1678.    d*   {set btn "dec"}
  1679.    fi*  {set btn "find"}
  1680.    fo*  {set btn "forward"}
  1681.    inc* {set btn "inc"}
  1682.    ind* {set btn "index"}
  1683.    n*   {if {$h4contents==""} {continue}; set btn "next"}
  1684.    o*   {set btn "open"}
  1685.    p*   {if {$h4contents==""} {continue}; set btn "prev"}
  1686.    ref* {set btn "refresh"}
  1687.    rel* {set btn "reload"}
  1688.    sea* {set btn "search"}
  1689.    sep* {grid columnconfig $gw [incr bcount] -minsize 5; continue}
  1690.    st*  {set btn "stop"}
  1691.    u*   {if {$h4contents==""} {continue}; set btn "up"}
  1692.    default {continue}
  1693.   }
  1694.   grid $gw.b$btn  -padx 0 -pady 0 -row 3 -column [incr bcount] \
  1695.                  -rowspan 1 -columnspan 1 -sticky news
  1696.  }
  1697.  updatehead
  1698. }
  1699.  
  1700. #-------------------------------------------------------------------------------
  1701. # Function       :  help::gettags
  1702. # Description    :  Configure and get tag for current text with attr
  1703. # Parameters     :  None
  1704. # Return         :  Tagname
  1705. #-------------------------------------------------------------------------------
  1706. proc help::gettags {} {
  1707.  variable _count
  1708.  variable _tags
  1709.  variable w
  1710.  variable settings
  1711.  variable font 
  1712.  variable fontfixed
  1713.  variable fontsize 
  1714.  variable curtopic
  1715.  variable data
  1716.  variable attr
  1717.  variable rmargin
  1718.  variable index
  1719.  variable interp
  1720.  
  1721.  if {[set justify [lindex $attr(justify) 0]]==""} {
  1722.   set justify [lindex $attr(justify,global) 0]
  1723.  }
  1724.  
  1725.  if {[info exists _tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin))]} {
  1726.   return $_tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin))
  1727.  }
  1728.  
  1729.  incr _count
  1730.  set color ""
  1731.  if {[lsearch $attr(style) "p"]==-1 && [lsearch $attr(style) "t"]==-1 && [lsearch $attr(style) "k"]==-1} {
  1732.   if {$attr(face)!=""} {
  1733.    append ffont "-family \{[lindex $attr(face) 0]\} "
  1734.   } else {
  1735.    append ffont "-family \{$font\} "
  1736.   }
  1737.  } else {
  1738.   append ffont "-family \{$fontfixed\} "
  1739.  }
  1740.  if {[lsearch $attr(style) "b"]!=-1} {
  1741.   append ffont "-weight bold "
  1742.  }
  1743.  if {[lsearch $attr(style) "i"]!=-1} {
  1744.   append ffont "-slant italic "
  1745.  }
  1746.  if {[lsearch $attr(style) "u"]!=-1} {
  1747.   append ffont "-underline 1 "
  1748.  }
  1749.  if {[lsearch $attr(style) "n"]==-1 && [lsearch $attr(style) "t"]==-1 && [lsearch $attr(style) "p"]==-1} {
  1750.   $w.text tag configure tag$_count -wrap word
  1751.  }
  1752.  if {$attr(sizes)!=""} {
  1753.   if {[set ind [string index [set size [lindex $attr(sizes) 0]] 0]]=="+" || $ind=="-"} {
  1754.    catch {append ffont "-size [expr $fontsize $size]"}
  1755.   } else {
  1756.    catch {append ffont "-size [expr $size]"}
  1757.   }
  1758.  } else {
  1759.   append ffont "-size $fontsize"
  1760.  }
  1761.  if {$attr(colors)!=""} {
  1762.   set color "[lindex $attr(colors) 0]"
  1763.  }
  1764.  if {$attr(bgcolors)!=""} {
  1765.   catch {$w.text tag configure tag$_count -background [lindex $attr(bgcolors) 0]}
  1766.  }
  1767.  catch {$w.text tag configure tag$_count -font $ffont}
  1768.  catch {$w.text tag configure tag$_count -foreground $color}
  1769.  catch {$w.text tag configure tag$_count -justify $justify}
  1770.  catch {$w.text tag configure tag$_count -lmargin1 $attr(margin) -lmargin2 $attr(margin) -rmargin $rmargin}
  1771.  if {[set lnk [lindex $attr(links) 0]]!=""} {
  1772.   $w.text tag configure tag$_count -underline 1
  1773.   catch {$w.text tag configure tag$_count -foreground $settings(link)}
  1774.   $w.text tag bind tag$_count <Enter> "$w.text configure -cursor hand2; catch {$w.text tag configure tag$_count -foreground \$help::settings(alink)}"
  1775.   if {![regexp "^tcl(script)?:(.*)" $lnk x lnk_type lnk]} {
  1776.    $w.text tag bind tag$_count <1> "help::show \{$lnk\}"
  1777.    if {[lindex $attr(link_titles) 0]!=""} {
  1778.     $w.text tag bind tag$_count <Enter> "+ set help::stat \{[lindex $attr(link_titles) 0]\}"
  1779.    } elseif {[info exists data([set ltopic [lindex [split $lnk "#"] 0]],title)]} {
  1780.     $w.text tag bind tag$_count <Enter> "+ set help::stat \{$data($ltopic,title)\}"
  1781.    } elseif {$ltopic=="" && [info exists data($curtopic,title)]} {
  1782.     $w.text tag bind tag$_count <Enter> "+ set help::stat \{$data($curtopic,title)\}"
  1783.    } elseif {$index==""} {
  1784.     $w.text tag bind tag$_count <Enter> "+ set help::stat \{$lnk\}"
  1785.    }
  1786.   } else {
  1787.    if {$lnk_type==""} {
  1788.     $w.text tag bind tag$_count <1> "if {\[catch \{namespace eval :: \{$lnk\}\}\]} {set help::data(__@Error@__,title) Error; set help::data(__@Error@__,text) \"<font color=red><pre>\$::errorInfo</pre></font>\"; help::show __@Error@__}"
  1789.    } else {
  1790.     $w.text tag bind tag$_count <1> "if {\[catch \{$interp eval \{$lnk\}\}\]} {set help::data(__@Error@__,title) Error; set help::data(__@Error@__,text) \"<font color=red><pre>\$::errorInfo</pre></font>\"; help::show __@Error@__}"
  1791.    }
  1792.    if {[lindex $attr(link_titles) 0]!=""} {
  1793.     $w.text tag bind tag$_count <Enter> "+ set help::stat \{[lindex $attr(link_titles) 0]\}"
  1794.    }
  1795.   }
  1796.   $w.text tag bind tag$_count <Leave> "$w.text configure -cursor arrow; catch {$w.text tag configure tag$_count -foreground \$help::settings(link)}; set help::stat \{Done.\}"
  1797.  }
  1798.  set _tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin)) tag$_count
  1799.  return tag$_count
  1800. }
  1801.  
  1802. #-------------------------------------------------------------------------------
  1803. # Function       :  help::gethr
  1804. # Description    :  Configure and get tag for horizontal line
  1805. # Parameters     :  width       - line width
  1806. # Return         :  Text with tags
  1807. #-------------------------------------------------------------------------------
  1808. proc help::gethr {height color} {
  1809.  variable _count
  1810.  variable w
  1811.  variable settings
  1812.  
  1813.  if {$color==""} {set color $settings(fore)}
  1814.  if {$height==""} {set height 1}
  1815.  incr _count
  1816.  $w.text tag configure tagh$_count -font "-size 1"
  1817.  catch {$w.text tag configure tagh$_count -background $settings(fore)}
  1818.  catch {$w.text tag configure tagh$_count -background $color}
  1819.  catch {$w.text tag configure tagh$_count -font "-size $height" -spacing3 0}
  1820.  return "\"\n\" h \"\n\" tagh$_count \"\n\" h"
  1821. }
  1822.  
  1823. #-------------------------------------------------------------------------------
  1824. # Function       :  help::show
  1825. # Description    :  Show topic
  1826. # Parameters     :  topic       - topic name
  1827. #                :  modhist     - modify or not history
  1828. # Return         :  Nothing
  1829. #-------------------------------------------------------------------------------
  1830. proc help::show {{topic contents} {modhist 1} {textpos {}}} {
  1831.  variable w
  1832.  variable gw
  1833.  variable attr
  1834.  variable abort 
  1835.  variable showing 
  1836.  variable stat
  1837.  variable data
  1838.  variable index
  1839.  variable linkcolor
  1840.  variable alinkcolor
  1841.  variable history
  1842.  variable hpos
  1843.  variable backcolor
  1844.  variable forecolor
  1845.  variable settings
  1846.  variable lmargin
  1847.  variable font
  1848.  variable fontsize
  1849.  variable curtopic
  1850.  variable curfilename
  1851.  variable _count
  1852.  variable _tags
  1853. # variable _images
  1854.  variable _text
  1855.  variable perc
  1856.  variable _istitle 0
  1857.  variable _isscript 0
  1858.  variable _istext 1
  1859.  variable _t_title
  1860. #sch vars for __Prev, __up1level, __Next 
  1861.  variable sequence 
  1862.  variable up1level 
  1863.  variable h4topics
  1864.  variable h4contents
  1865. #/sch
  1866.  variable _need_tag ""
  1867.  variable controls
  1868.  variable insearch
  1869.  variable btninfo
  1870.  variable interp
  1871.  variable tables
  1872.  
  1873.  switch -exact -- $topic {
  1874.   __dec     {event generate $w.text <Control-bracketleft>; return}
  1875.   __find    {dlgfind:init; return}
  1876.   __inc     {event generate $w.text <Control-bracketright>; return}
  1877.   __open    {event generate $w.text <Control-o>; return}
  1878.   __refresh {event generate $w.text <Control-r>; return}
  1879.   __reload  {event generate $w.text <Control-l>; return}
  1880.   __stop    {set abort 1; return}
  1881.   __search  {dlgfind:init 0; return}
  1882.  }
  1883.  
  1884.  set mark ""
  1885.  if {[set pos [string first "#" $topic]]!=-1} {
  1886.   set mark  [string tolower [string range $topic [expr $pos + 1] end]]
  1887.   set topic [string range $topic 0 [expr $pos - 1]]
  1888.  }
  1889.  
  1890.  if {$topic==""} {
  1891.   set topic $curtopic
  1892.   if {$topic==""} {
  1893.    set topic "contents"
  1894.   }
  1895.  }
  1896.  
  1897.  if {$curtopic==$topic || ($index=="" && $curtopic==[file join [file dirname $curfilename] $topic])} {
  1898.   if {$mark!=""} {
  1899.    if {$modhist} {
  1900.     if {[llength $history] && $hpos==[expr [llength $history]-1]} {
  1901.      set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
  1902.     }
  1903.     catch {set history [lrange $history 0 $hpos]}
  1904.     if {[lindex [lindex $history end] 0]!="$curtopic#$mark"} {
  1905.      lappend history [list "$curtopic#$mark" 0]
  1906.     }
  1907.     set hpos [expr [llength $history] - 1]
  1908.    }
  1909.    showmark "mark_$mark"
  1910.   } else {
  1911.    if {$textpos!=""} {
  1912.     showpos $textpos
  1913.    }
  1914.   }
  1915.   return
  1916.  }
  1917.  
  1918.  if {$showing} {
  1919.   set abort 1
  1920.   catch {after cancel "help::show $topic $modhist"}
  1921.   after 200 "help::show $topic $modhist"
  1922.   return
  1923.  }
  1924.  set abort 0
  1925.  set showing 1
  1926.  bind $w.text <Control-r> ""
  1927.  
  1928. #sch find topic for __up1level, __Prev and __Next
  1929.  if {$topic=="__up1level"} {
  1930.   set topic $up1level($curtopic)
  1931.  }
  1932.  if {$topic=="__Prev" || $topic=="__Next"} {
  1933.   set i [lsearch $sequence $curtopic]
  1934.   if {$topic=="__Prev"} {
  1935.    incr i -1
  1936.   } else {
  1937.    incr i +1
  1938.   }
  1939.   set topic [lindex $sequence $i]
  1940.  }
  1941. #/sch
  1942.  
  1943.  if {$topic=="__prev" || $topic=="__next"} {
  1944.   set showing 0
  1945.   if {[llength $history]} {
  1946.    set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
  1947.   }
  1948.   [string range $topic 2 end]
  1949.   return
  1950.  }
  1951.  
  1952.  if {$modhist && [llength $history] && $hpos==[expr [llength $history]-1]} {
  1953.   set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
  1954.  }
  1955.  
  1956.  set curtopic $topic
  1957.  
  1958.  if {$topic!="" && $index!=""} {
  1959.   if {[lsearch $index $topic]==-1} {
  1960.    if {$topic=="contents"} {
  1961.     set showing 0
  1962.     show __index
  1963.     return
  1964.    } else {
  1965.     if {[string match "__@*@__" $topic]} {
  1966.      if {[catch {set _text $data($topic,text); set title $data($topic,title)}]} {
  1967.       set showing 0
  1968.       show contents
  1969.       return
  1970.      }
  1971.     } else {
  1972.      set _text "<font color=#c00000>Topic</font> <b>\"$topic\"</b> <font color=#c00000>not found in</font> <b>\"[file join [pwd] $curfilename]\"</b><font color=#c00000>!</font>"
  1973.      set title "Topic not found!"
  1974.     }
  1975.    }
  1976.   } else {
  1977.    set _text  $data($topic,text)
  1978.    set title $data($topic,title)
  1979.    if {$index=="__file_error"} {
  1980.     set index ""
  1981.    }
  1982.   }
  1983.  } else {
  1984.    if {[string match "__@*@__" $topic]} {
  1985.     if {[catch {set _text $data($topic,text); set title $data($topic,title)}]} {
  1986.      set showing 0
  1987.      show contents
  1988.      return
  1989.     }
  1990.    } else {
  1991.     if {$topic=="contents"} {
  1992.      set topic $curfilename
  1993.     }
  1994.     set topic [file join [file dirname $curfilename] $topic]
  1995.     # make it an absolute path
  1996.     if {[file exists [file dirname $topic]]} {
  1997.      set oldpath [pwd]
  1998.      cd  [file dirname $topic]
  1999.      set absdir [pwd]
  2000.      cd  $oldpath
  2001.      unset oldpath
  2002.      set topic [file join $absdir [file tail $topic]]
  2003.     }
  2004.     if {![load $topic]} {
  2005.      set showing 0
  2006.      catch {set history [lrange $history 0 $hpos]}
  2007.      if {[lindex [lindex $history end] 0]!="$topic#$mark"} {
  2008.       lappend history [list "$topic#$mark" 0]
  2009.      }
  2010.      set hpos [expr [llength $history] - 1]
  2011.      show __file_error 0
  2012.      return
  2013.     }
  2014.     set _text  $data(text)
  2015.     regsub -all -- "\[\r\n \]+" $data(title) " " data(title)
  2016.     set title $data(title)
  2017.     set curtopic $topic
  2018. #    set curtopic $curfilename
  2019. #    set topic $curfilename
  2020.    }
  2021.  }
  2022.  
  2023.  if {$modhist} {
  2024.   catch {set history [lrange $history 0 $hpos]}
  2025.   if {[lindex [lindex $history end] 0]!="$topic#$mark"} {
  2026.    lappend history [list "$topic#$mark" 0]
  2027.   }
  2028.   set hpos [expr [llength $history] - 1]
  2029.  }
  2030.  
  2031. #sch get position for __Prev and __Next 
  2032.  set spos [lsearch $sequence $curtopic]
  2033. #/sch
  2034.  catch {unset _tags}
  2035.  catch {unset tables}
  2036.  array set tables "level 0 stack {} count 0 tables {}"
  2037.  catch {interp delete $interp}
  2038.  catch {set interp [interp create]}
  2039.  catch {$interp alias g_eval ::eval}
  2040.  catch {$interp alias img_change ::help::img_change}
  2041.  catch {$interp alias id_change  ::help::id_change }
  2042.  catch {$interp alias id_visible ::help::id_visible}
  2043.  catch {$interp eval [list set script_dir [file dirname $curfilename]]}
  2044.  
  2045.  
  2046.  bind $w.text <Control-r> "set help::curtopic {}; help::show $topic"
  2047.  
  2048.  set stat "Creating title..."
  2049.  update
  2050.  if {$title==""} {set title "Untitled"}
  2051.  $w.title delete all
  2052.  array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
  2053.  catch {$w.title configure -foreground $settings(fore)}
  2054.  catch {$w.title configure -background $settings(back)}
  2055.  catch {$w.text configure -foreground $settings(fore)}
  2056.  catch {$w.text configure -background $settings(back)}
  2057.  set _t_title(title) [$w.title create text 4 4 -anchor nw -fill $settings(fore) -text $title \
  2058.                      -font "-family $font -size [expr $fontsize + 12] -weight bold"]
  2059.  
  2060.  set inc [font metrics "-family $font -size [expr $fontsize + 12] -weight bold" -displayof $w -ascent]
  2061.  set spc [font measure "-family $font -size [expr $fontsize - 2]" -displayof $w.title "    "]
  2062.  
  2063.  set x 4
  2064.  foreach control $controls {
  2065.   switch -glob -- $control {
  2066.    b*   {set link "__prev"}
  2067.    c*   {set link "contents"}
  2068.    d*   {set link "__dec"}
  2069.    fi*  {set link "__find"}
  2070.    fo*  {set link "__next"}
  2071.    inc* {set link "__inc"}
  2072.    ind* {set link "__index"}
  2073.    n*   {set link "__Next"}
  2074.    o*   {set link "__open"}
  2075.    p*   {set link "__Prev"}
  2076.    ref* {set link "__refresh"}
  2077.    rel* {set link "__reload"}
  2078.    sea* {set link "__search"}
  2079.    sep* {incr x $spc; continue}
  2080.    st*  {set link "__stop"}
  2081.    u*   {set link "__up1level"}
  2082.    default {continue}
  2083.   }
  2084.   foreach {txt vis expr btn} $btninfo($link) {
  2085.    if {[expr $vis]} {
  2086.     if {[expr $expr]} {
  2087.      set _t_title($link) [$w.title create text $x [expr $fontsize + $inc] -anchor nw -fill $settings(fore) \
  2088.                          -text $txt -font "-family $font -size [expr $fontsize - 2] -underline 1"]
  2089.      catch {$w.title itemconfigure $_t_title($link) -fill $settings(link)}
  2090.      $w.title bind $_t_title($link) <1> "help::show \{$link\}"
  2091.      $w.title bind $_t_title($link) <Enter> "$w.title configure -cursor hand2; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(alink)}; set help::stat \{$txt\}"
  2092.      $w.title bind $_t_title($link) <Leave> "$w.title configure -cursor arrow; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(link)}; set help::stat \{Done.\}"
  2093.     } else {
  2094.      set _t_title($link) [$w.title create text $x [expr $fontsize + $inc] -anchor nw -fill $settings(fore) \
  2095.                          -text $txt -font "-family $font -size [expr $fontsize - 2]"]
  2096.     }
  2097.     set x [expr [lindex [$w.title bbox $_t_title($link)] 2] + $spc]
  2098.    }
  2099.   }
  2100.  }
  2101. #/sch
  2102.  updatehead "__prev __next __stop __Prev __Next __up1level contents __index __search"
  2103.  
  2104.  if {$controls!=""} {
  2105.   incr inc [expr 4 + [font metrics "-family $font -size [expr $fontsize - 2]" -displayof $w -linespace]]
  2106.  }
  2107.  incr inc [font metrics "-family $font -size [expr $fontsize - 2]" -displayof $w -ascent]
  2108.  set _t_title(line) [$w.title create line 0 $inc 5000 $inc -width 2 -fill $settings(fore)]
  2109.  
  2110.  foreach {x1 y1 x2 y2} [$w.title bbox all] {break}
  2111.  $w.title configure -scrollregion "$x1 $y1 $x2 $y2" -height [expr $y2 - $y1]
  2112.  $w.title xview moveto 0 ; $w.title yview moveto 0
  2113.  
  2114.  if {[string match {.tophelpwindow*} $w]} {
  2115.   wm title .tophelpwindow "Help - $title"
  2116.  }
  2117.  
  2118.  set stat "Displaying..."
  2119.  set perc 0
  2120.  catch {after cancel "help::updatestate"}
  2121.  after 250 "help::updatestate"
  2122.  catch {after cancel "help::update_d"}
  2123.  after 100 "help::update_d"
  2124.  update
  2125.  $w.text configure -state normal
  2126.  $w.text delete 1.0 end
  2127.  eval "$w.text mark unset [$w.text mark names]"
  2128.  if {$textpos!=""} {
  2129.   showpos $textpos
  2130.  }
  2131.  set attr(span) ""
  2132.  set attr(style) ""
  2133.  set attr(ul_type) ""
  2134.  set attr(indent) ""
  2135.  set attr(tag_fonts) ""
  2136.  set attr(face) ""
  2137.  set attr(links) ""
  2138.  set attr(link_titles) ""
  2139.  set attr(colors) ""
  2140.  set attr(bgcolors) ""
  2141.  set attr(tables) ""
  2142.  set attr(sizes) ""
  2143.  set attr(justify) ""
  2144.  set attr(justify,global) ""
  2145.  set attr(margin) $lmargin
  2146.  set _count 0
  2147.  set data(title) ""
  2148.  set deltags [lrange [$w.text tag names] 2 end]
  2149.  catch {eval "$w.text tag delete $deltags"}
  2150.  catch {$w.text tag configure fnd -foreground [$w.text tag cget sel -foreground] \
  2151.                                   -background [$w.text tag cget sel -background]}
  2152.  if {$h4topics=="" && $h4contents==""} {
  2153.   regsub -all -- {<!--.*?-->} $_text "" _all_text
  2154.  } else {
  2155.   set _all_text $_text
  2156.  }
  2157.  set totallen [string length $_all_text]
  2158.  set _text_pos 0
  2159. #main cycle
  2160.  while {!$abort && $_text_pos!=$totallen} {
  2161.   set pos [string first "<" [string range $_all_text [expr {$_text_pos + 1024}] end]]
  2162.   if {$pos==-1} {
  2163.    set _text [string range $_all_text $_text_pos end]
  2164.    set _text_pos $totallen
  2165.   } else {
  2166.    set _text [string range $_all_text $_text_pos [expr {$_text_pos + 1024 + $pos - 1}]]
  2167.    set _text_pos [expr {$_text_pos + 1024 + $pos}]
  2168.   }
  2169.   set perc [format %2.1f [expr ($_text_pos - [string length $_text]) * 100 / $totallen.0]]
  2170.   update
  2171.   while {!$abort && [set pos [string first "<" $_text]]!=-1} {
  2172.    set outtext [string range $_text 0 [expr {$pos - 1}]]
  2173.    set _text [string range $_text $pos end]
  2174.    if {$_istitle} {
  2175.     append data(title) $outtext
  2176.    } elseif {$_isscript} {
  2177.     append data(script) $outtext
  2178.     if {![regexp -nocase "^\<\[\r\t\n \]*\/script" $_text]} {
  2179.      append data(script) "<"
  2180.      set _text [string range $_text 1 end]
  2181.      continue
  2182.     }
  2183.    } elseif {$_istext} {
  2184.     if {[lsearch $attr(style) "p"]==-1} {
  2185.      if {[$w.text get "end -2c"]=="\n"} {
  2186.       set outtext [string trimleft $outtext " \t\n"]
  2187.      }
  2188.      regsub -all -- "\[\r\t\n \]+" $outtext " " outtext
  2189.     }
  2190. #sch
  2191.     $w.text insert end [specialentities $outtext] [gettags]
  2192. #/sch
  2193.    }
  2194.    if {[set pos [string first ">" $_text]]!=-1} {
  2195.     set tag [string trim [string range $_text 0 $pos] "< >\t\n"]
  2196.     set _text [string range $_text [incr pos] end]
  2197.    } else {
  2198.     set tag [string trim $_text "< >\t\n"]
  2199.     set _text ""
  2200.    }
  2201.    regsub -all -- "\[\r\t\n \]+" $tag " " tag
  2202.    if {[set pos [string first " " $tag]]!=-1} {
  2203.     set tagparams [parsetag [string range $tag $pos end]]
  2204.     set tag [string range $tag 0 [expr $pos - 1]]
  2205.    } else {
  2206.     set tagparams ""
  2207.    }
  2208.    set tag [string tolower $tag]
  2209.    catch {tag_$tag $tagparams}
  2210.   }
  2211.   if {!$abort} {
  2212.    if {!$_istitle && !$_isscript && $_istext} {
  2213.     if {[lsearch $attr(style) "p"]==-1} {
  2214.      if {[$w.text get "end -2c"]=="\n"} {
  2215.       set _text [string trimleft $_text " \t\n"]
  2216.       if {$_text_pos==$totallen} {
  2217.        set _text [string trimright $_text " \t\n"]
  2218.       }
  2219.      }
  2220.      regsub -all -- "\[\r\t\n \]+" $_text " " _text
  2221.     }
  2222. #sch
  2223.     $w.text insert end [specialentities $_text] [gettags]
  2224. #/sch
  2225.    } elseif {$_isscript} {
  2226.     append data(script) "$_text"
  2227.    }
  2228.   }
  2229.  } 
  2230.  
  2231.  if {!$abort && $_isscript} {
  2232.   append data(script) "$_text"
  2233.   catch {tag_/script ""}
  2234.  }
  2235.  set abort 0
  2236.  set showing 0
  2237.  while {$tables(stack)!=""} {
  2238.   tag_/td {}
  2239.  }
  2240.  updatehead 
  2241.  $w.text configure -cursor arrow
  2242.  $w.text configure -state disabled
  2243.  $w.text tag raise fnd
  2244.  $w.text tag raise sel
  2245.  set stat "Done."
  2246. }
  2247.  
  2248. #-------------------------------------------------------------------------------
  2249. # Function       :  help::updatehead
  2250. # Description    :  
  2251. # Parameters     :  None
  2252. # Return         :  Nothing
  2253. #-------------------------------------------------------------------------------
  2254. proc help::updatehead {{what "__prev __next __inc __dec __stop __Prev __Next __up1level"}} {
  2255.  variable w
  2256.  variable history
  2257.  variable hpos
  2258.  variable _t_title
  2259.  variable settings
  2260.  variable font
  2261.  variable fontsize
  2262.  variable showing
  2263.  variable insearch
  2264.  variable sequence
  2265.  variable curtopic
  2266.  variable up1level
  2267.  variable btninfo
  2268.  
  2269.  foreach link $what {
  2270.   foreach {txt vis expr btn } $btninfo($link) {
  2271.    if {[expr $expr]} {
  2272.     catch {$w.[set btn] configure -state normal} 
  2273.     catch {
  2274.      $w.title itemconfigure $_t_title($link) -font "-family $font -size [expr $fontsize - 2] -underline 1"
  2275.      catch {$w.title itemconfigure $_t_title($link) -fill $settings(link)}
  2276.      $w.title bind $_t_title($link) <1> "help::show \{$link\}"
  2277.      $w.title bind $_t_title($link) <Enter> "$w.title configure -cursor hand2; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(alink)}; set help::stat \{$txt\}"
  2278.      $w.title bind $_t_title($link) <Leave> "$w.title configure -cursor arrow; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(link)}; set help::stat \{Done.\}"
  2279.     }
  2280.    } else {
  2281.     catch {$w.[set btn] configure -state disabled}
  2282.     catch {
  2283.      $w.title itemconfigure $_t_title($link) -font "-family $font -size [expr $fontsize - 2] -underline 0"
  2284.      catch {$w.title itemconfigure $_t_title($link) -fill $settings(fore)}
  2285.      $w.title bind $_t_title($link) <1> ""
  2286.      $w.title bind $_t_title($link) <Enter> ""
  2287.      $w.title bind $_t_title($link) <Leave> ""
  2288.      $w.title configure -cursor arrow
  2289.     }
  2290.    }
  2291.   }
  2292.  }
  2293. }
  2294.  
  2295. #-------------------------------------------------------------------------------
  2296. # Function       :  help::prev
  2297. # Description    :  Show previous topic
  2298. # Parameters     :  None
  2299. # Return         :  Nothing
  2300. #-------------------------------------------------------------------------------
  2301. proc help::prev {} {
  2302.  variable w
  2303.  variable history
  2304.  variable hpos
  2305.  
  2306.  if {$hpos>0} {
  2307.   set tpos [lindex [lindex $history [incr hpos -1]] 1] 
  2308.   if {[set pos [string first "#" [set topic [lindex [lindex $history $hpos] 0]]]]!=-1} {
  2309.    set topic [string range $topic 0 [expr $pos - 1]]
  2310.   }
  2311.   show $topic 0 $tpos
  2312.  }
  2313. }
  2314.  
  2315. #-------------------------------------------------------------------------------
  2316. # Function       :  help::next
  2317. # Description    :  Show next topic
  2318. # Parameters     :  None
  2319. # Return         :  Nothing
  2320. #-------------------------------------------------------------------------------
  2321. proc help::next {} {
  2322.  variable w
  2323.  variable history
  2324.  variable hpos
  2325.  
  2326.  if {$hpos<[expr [llength $history] - 1]} {
  2327.   set tpos [lindex [lindex $history [incr hpos]] 1]
  2328.   if {[set pos [string first "#" [set topic [lindex [lindex $history $hpos] 0]]]]!=-1} {
  2329.    set topic [string range $topic 0 [expr $pos - 1]]
  2330.   }
  2331.   show $topic 0 $tpos
  2332.  }
  2333. }
  2334.  
  2335. #-------------------------------------------------------------------------------
  2336. # Function       :  help::reg                                        
  2337. # Description    :  Assign help topic to widget
  2338. # Parameters     :  widget      - widget path
  2339. #                :  filename    - name of file with help
  2340. #                :  topic       - topic name
  2341. # Return         :  Nothing
  2342. #-------------------------------------------------------------------------------
  2343. proc help::reg {widget filename topic {parent {}} {event {<F1>}} {width 450} {height 400}} {
  2344.  variable regs
  2345.  
  2346.  if {$filename=="" || $topic==""} {
  2347.   if {[info exists $regs($widget)]} {
  2348.    bind $widget $event ""
  2349.    unset regs($widget)
  2350.   }
  2351.  } else {
  2352.   bind $widget $event "help::init \{$filename\} \{$topic\} \{$parent\} $width $height; break"
  2353.   set regs($widget) 1
  2354.  }
  2355. }
  2356.  
  2357. #-------------------------------------------------------------------------------
  2358. # Function       :  help::updatestate                                          
  2359. # Description    :  Update statusbar every 1/4 of seconds
  2360. # Parameters     :  None
  2361. # Return         :  Nothing
  2362. #-------------------------------------------------------------------------------
  2363. proc help::updatestate {} {
  2364.  variable perc
  2365.  variable stat
  2366.  variable showing
  2367.  
  2368.  if {$showing} {
  2369.   set stat "Displaying... $perc%."
  2370.   after 250 "help::updatestate"
  2371.  }
  2372. }
  2373.  
  2374. #-------------------------------------------------------------------------------
  2375. # Function       :  help::update_d                                              
  2376. # Description    :  Update animated image
  2377. # Parameters     :  None
  2378. # Return         :  Nothing
  2379. #-------------------------------------------------------------------------------
  2380. proc help::update_d {} {
  2381.  variable gw
  2382.  variable _images
  2383.  variable _dnum
  2384.  variable showing
  2385.  
  2386.  if {$showing} {
  2387.   incr _dnum
  2388.   if {$_dnum>3} {set _dnum 1}
  2389.   $gw.d configure -image $_images(d[set _dnum])
  2390.   after 200 "help::update_d"
  2391.  }
  2392. }
  2393.  
  2394. #-------------------------------------------------------------------------------
  2395. # Function       :  help::show_about                                           
  2396. # Description    :  Show about text
  2397. # Parameters     :  None
  2398. # Return         :  Nothing
  2399. #-------------------------------------------------------------------------------
  2400. proc help::show_about {} {
  2401.  variable data
  2402.  
  2403.  set data(__@AbOuT@__,text) "<body text=black bgcolor=#ffffd2 link=navy>
  2404.      <p><img src=\"__@LoGo@__\"></p>
  2405.      <p>(c) Copyright by <b><font color=navy>Andrei A. Gratchev</font></b>,
  2406.      <font color=navy>Russia</font>, <font color=navy>Moscow</font>,
  2407.      <font color=navy>2000</font> - <font color=navy>2003</font><br>
  2408.      E-Mail: <font color=navy><u><tt><a href=mailto:grand@deversys.com>grand@deversys.com</a></tt></u></font>
  2409.      </p><br><p><font size=-1>Special thanks to:<ul><li><kbd>J.W.Schmitz-Hübsch
  2410.      </kbd><br> for implementations of additional features<li><kbd>Dave Clews</kbd><br>
  2411.      for help in translation of in-line documentation</ul></font></p>"
  2412.  set data(__@AbOuT@__,title) "About"
  2413.  if {![info exists data(__@LoGo@__,image)]} {
  2414.   set data(__@LoGo@__,image) [image create photo -data \
  2415.     "R0lGODlhowBFAPf/AAMDCQUFCgMDBgsLDfDw8efn6MnJyjM1ai8xYTc8eCksVzA3bz9IjiMoTB4hOQkKEUhWpgUHET1Nm0BQnzZEhBwjRCIuYik3cx4oUBMZMiczZSgyWzA5YhUZKnmFum10kRElbBEjZBUmYhkraRQiUhEdRhkpYQ0VMx0vbQcLGhwrXxsoWRomVCQ0bSc4dBolTC0/fgUHDhcgPzZKkiAsVxYdNiEoQRASGT5E
  2416.      WxUXHo2UrMrP4g4ndBYvexUrcxcrbhcrahovchktbhcpZRYoYBQkVxEfSxktaxUmWw0XOBAcQg8aPQsTLAkPIx4zdCA1eRssZQgNHh4vZyAyayQ3dhYiRyg8fgwSJSs9dSg4aklYijM7VlZhhE1TZmZrfA8rexgzfwMGDhw1fh04ghIhTiU+hQYKFS1FjCw9bT5VlDtPh0hemzVFclRooEJPc2Bzp0dVe1lolEFLaG19rC40RVNc
  2417.      dIyZvV1jdIaNol5haY6SnQMFCg0PFH2NtXeEppikwjo+SKewx5qhssXK1lNZZ6Sru6WorykrL7nAzq+0vjQ1N+rr7d/g4pWdq4OKlh0eH2ZoatTW2Li5un+FiG1xc8/S0wIDA3R4d56iob7Av2tubJWYlU9QT7Kzsn2Aetzd2tHVxMnNusfKtLCypGtsZc7QvcfJsGRlWWhpXdrcwuvs3PDx5Pf5z/X3zfP1y/X3z7m6nru8o7y9
  2418.      pvX24u/wxtvct8PEpP//0fr6zv//0/390fX1yvPzycnJpvf3zeXlvtDQrbe3mP//1f390/Pzy+rqw9TUscDAoLq6m/f3z/X1zczMq///1/391fr60vHxy7GxlaOjifX1z///2f391/Pzzvv71qurkpeXgYqKdm1tXf//2/392XJyYv//3f3928fHrGFhVPv72v//3/393fT01erqzXl5arKynf//4v394PX121RUS/j43sDArP//
  2419.      5vr64v//6vv76HFxaVlZU0pKRUFBPfb26mRkYV5eXP////39/fr6+vX19SQkJAgICCwAAAAAowBFAAAI/wBz5WI2bZu3ceO8edvGTJjAWxAjSrwlMJcwYcwITtvIMWNDhxUnihxJsqTJkyhTqlwp0eI0b+liyvQ2rWGukgIvEjSIsGdPhdu21bT5kKXRo0iTKsUI8927ePGcpmMoTBcuXRNz7oQZ06lXqTIRLhwKUqnZs2iTCps2
  2420.      Ll2BHTsGDUKEKJIzZbx24Wppkdm2tl6hCh78NSZCoUTTKl7MOKKwv+92BPpjp8+cOYVS1fpFay/EnC/TORW8ilGkuXTpVorESB7YhDUdNp5NG6nftoMoe3izZo0Od7aA/dr1eSBb0VDvRZpMuXKf59D72PmD6NMsdeOo5sJau7t3krfhIf/qszvNGTV+rkE7VosXxYF/kcurNLnynDdv2ujXj//yHD/PJfKJONY448tV3yWYoF/k
  2421.      tIPIfWuM8QQMH2CDDTTG0KKLS4DFU0B9u60xQxlWlFhiGWWckcYa/LWBnw6p/FIMLb4oaGNtj33TTiC8zdBDEFRw4Uk20fRSjC5rNRUPI5T18UYaZTyBghRQVCmFFFO04MQTVqQ4wwxqaBGHO+AY84t7N6a52FrfrMPjGmf8GOQ5nkRjSzHO+IUck3bM0UYZTgxBhApSZOHGoW6gocEUWDqxJZcUaHENOsdkqOalaLHpJm9xAsnF
  2422.      POdgc6czx71TAGVzrCEGEEhAwcYdmpD/gk8++eCDDyR31IFGC1OgcMQUF7BhITTLHInpsUhp+manQZIS6jF4boNcIH2qKmgWd5BCDyf1dOstJ/TkQ8odbLRwZRZs0InNMb94huy7KSnLqZxcOLvuL9Y0FYkdHrQxBqtZUJIPJ/YoYo893nbLDjvhjssGGmi4gc882ATTLrwYnyQvnPTaCy01gP3h5AxBiCCFF/nUY3A97IRzijYw
  2423.      a4NKOOGEa2sdcMBBDyrZBFNLjRkHLdLGzNb7bDEgp6OKZf7+YEId+KhsDzvaZINNNFhjjU0253SDyin00ENIHOzw7DPQQqd9C9EdH81NW5U4mQYYQEBxBz3dhnNONNDY/7IMMIAv08sx0ETDtTY150NPN/eirXbQbHvqcTFvp/NgGz4e0QIkeIeTzTW2GLNZMaQX80stxvSCjOHnwNzN57384vjjGEferNvjwFPIvCigoUk+ehdZ
  2424.      y4y7+GK8L7vwYnotywQTzdZX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VrFmbSVqkxdCoUWPJl2a
  2450.      NFocqVWn3tLa9WvYsWXPpk3H9qtt3Ll1776tyLeiQ8GFDyde3Lg/5MmRK+oGa/MtX8auTbpU3fp17Nm1X6LU3ft38OHFjyf/XdN59OnVrz9Pyv17+PHlk0JV3/59/Pntn+If7lQ3bIDxJatbdKHFGFtkkSUWBht08EEII5RwQgortLBBWDLUcEMOO/TwQxBDzBAZEkskMRgUg0EGmGJ0IbBAX3bhZUYaa7TxRhxz1HFHHnv08Ucg
  2451.      gxTSFxdvCQgAO5NUckkmm3TySWB8kXJKKqu08sors9FySy679PJLL3sRZkEyyzTzTDTTVHNNNtt08004JwsIADs="]
  2452.  }
  2453.  append data(__@AbOuT@__,text) "<br><br><font size=-1 color=#303030><p>System info:<ul>
  2454.      <li>Tcl/Tk version: $::tcl_version/$::tk_version<li>OS: $::tcl_platform(os), 
  2455.      $::tcl_platform(osVersion) on $::tcl_platform(machine)</ul></p></font>"
  2456.  show "__@AbOuT@__"
  2457. }
  2458.  
  2459. #-------------------------------------------------------------------------------
  2460. # Function       :  help::destroy
  2461. # Description    :  Destroy handler
  2462. # Parameters     :  None
  2463. # Return         :  Nothing
  2464. #-------------------------------------------------------------------------------
  2465. proc help::destroy {{top 0}} {
  2466.  variable gw
  2467.  variable abort
  2468.  variable showing
  2469.  variable data
  2470.  variable curfilename
  2471.  variable curtopic
  2472.  
  2473.  if {$showing} {
  2474.   set abort 1
  2475.   after 200 "help::destroy $top"
  2476.  } else {
  2477.   catch {::destroy .dlgfind}
  2478.   foreach imn [array names data *,image] {
  2479.    catch {image delete $data($imn)}
  2480.   }
  2481.   catch {unset data}
  2482.   set curfilename ""
  2483.   set curtopic ""
  2484.   if {[info exists gw] && [winfo exists $gw]} {
  2485.    if {[string match {.tophelpwindow*} $gw]} {
  2486.     ::destroy [winfo toplevel $gw]
  2487.    } else {
  2488.     if {[wm protocol [winfo toplevel $gw] WM_DELETE_WINDOW]=="help::destroy 1"} {
  2489.      wm protocol [winfo toplevel $gw] WM_DELETE_WINDOW ""
  2490.     }
  2491.     if {$top} {
  2492.      ::destroy [winfo toplevel $gw]
  2493.     } else {
  2494.      pack forget $gw
  2495.      ::destroy $gw
  2496.     }
  2497.    }
  2498.   }
  2499.  }
  2500. }
  2501.  
  2502. #-------------------------------------------------------------------------------
  2503. # Function       :  help::parsetag
  2504. # Description    :  Parsing string to list
  2505. # Parameters     :  tagparams   -
  2506. # Return         :  List of parsed params {name value name value ...}
  2507. #-------------------------------------------------------------------------------
  2508. proc help::parsetag {tagparams} {
  2509.  set res ""
  2510.  set tagparams [string trim $tagparams]
  2511.  while {$tagparams!=""} {
  2512.   if {[set sp [string first " " $tagparams]]==-1} {
  2513.    set sp 99999999
  2514.   }
  2515.   if {[set i [string first "=" $tagparams]]!=-1 && $i<$sp} {
  2516.    set param [string tolower [string trim [string range $tagparams 0 [expr $i-1]]]]
  2517.    incr i
  2518.    set tagparams [string trim [string range $tagparams $i end]]
  2519.    set lastC [string index $tagparams 0]
  2520.    if {$lastC!="\"" && $lastC!="\'"} {
  2521.     set lastC " "
  2522.    } else {
  2523.     set tagparams [string range $tagparams 1 end]
  2524.    }
  2525.    if {[set i [string first $lastC $tagparams]]==-1} {
  2526.     set value $tagparams
  2527.     set tagparams ""
  2528.    } else {
  2529.     set value [string range $tagparams 0 [expr $i-1]]
  2530.     incr i
  2531.     set tagparams [string trim [string range $tagparams $i end]]
  2532.    }
  2533.   } else {
  2534.    set param [string tolower [string trim [string range $tagparams 0 [expr $sp-1]]]]
  2535.    set tagparams [string trim [string range $tagparams $sp end]]
  2536.    set value ""
  2537.   }
  2538.   lappend res $param $value
  2539.  }
  2540.  return $res
  2541. }
  2542.  
  2543. #-------------------------------------------------------------------------------
  2544. # Function       :  help::showmark
  2545. # Description    :  Goto mark anisochronously
  2546. # Parameters     :  mark        - name of mark
  2547. # Return         :  Nothing
  2548. #-------------------------------------------------------------------------------
  2549. proc help::showmark {mark} {
  2550.  variable w
  2551.  variable showing
  2552.  
  2553.  if {[catch {$w.text yview $mark}] && $showing} {
  2554.   after 200 "help::showmark \{$mark\}"
  2555.  } else {
  2556.   updatehead "__prev __next"
  2557.  }
  2558.  catch {$w.text see $mark}
  2559. }
  2560.  
  2561. #-------------------------------------------------------------------------------
  2562. # Function       :  help::showpos
  2563. # Description    :  Goto mark anisochronously
  2564. # Parameters     :  mark        - name of mark
  2565. # Return         :  Nothing
  2566. #-------------------------------------------------------------------------------
  2567. proc help::showpos {pos} {
  2568.  variable gw
  2569.  variable showing
  2570.  
  2571.  if {$showing && [$gw.text get $pos]==""} {
  2572.   after 200 "help::showpos \{$pos\}"
  2573.  } else {
  2574.   catch {$gw.text yview $pos}
  2575.   catch {$gw.text see $pos}
  2576.   updatehead "__prev __next"
  2577.  }
  2578. }
  2579.  
  2580. #-------------------------------------------------------------------------------
  2581. # Function       :  help::open
  2582. # Description    :  Show "Open" dialog and open help
  2583. # Parameters     :  None
  2584. # Return         :  Nothing
  2585. #-------------------------------------------------------------------------------
  2586. proc help::open {} {
  2587.  variable gw
  2588.  variable curfilename
  2589.  
  2590.  set tk_strictMotif 0
  2591.  set filetypes {
  2592.           {"Help files"   {.help}         TEXT}
  2593.           {"HTML files"   {.htm .html}    TEXT}
  2594.           {"All files"    {*}                 }
  2595.           }
  2596.  set res [tk_getOpenFile -filetypes $filetypes -parent $gw \
  2597.          -initialdir [file dirname $curfilename]]
  2598.  if {$res!=""} {
  2599.   help::init $res
  2600.  } else {
  2601.   if {$curfilename==""} {
  2602.    destroy
  2603.   }
  2604.  }
  2605. }
  2606.  
  2607. #-------------------------------------------------------------------------------
  2608. # Function       :  help::rightclick
  2609. # Description    :  Show popup menu
  2610. # Parameters     :  x & y   - position
  2611. # Return         :  Nothing
  2612. #-------------------------------------------------------------------------------
  2613. proc help::rightclick {x y} {
  2614.  variable gw
  2615.  variable fontsize
  2616.  variable index
  2617.  variable hpos
  2618.  variable history
  2619.  variable showing
  2620.  variable insearch
  2621.  
  2622.  $gw.menu entryconfigure "Back" -state [expr {($hpos>0)?"normal":"disabled"}]
  2623.  $gw.menu entryconfigure "Forward" -state [expr {($hpos<([llength $history] - 1))?"normal":"disabled"}]
  2624.  $gw.menu entryconfigure "Stop" -state [expr {($showing || $insearch)?"normal":"disabled"}]
  2625.  $gw.menu entryconfigure "Copy" -state [expr {([catch {selection get}])?"disabled":"normal"}]
  2626.  $gw.menu entryconfigure "Increase font size" -state [expr {($fontsize<30)?"normal":"disabled"}]
  2627.  $gw.menu entryconfigure "Decrease font size" -state [expr {($fontsize>6)?"normal":"disabled"}]
  2628.  $gw.menu entryconfigure "Search in topics..." -state [expr {([llength $index])?"normal":"disabled"}]
  2629.  tk_popup $gw.menu $x $y
  2630. }
  2631.  
  2632. #-------------------------------------------------------------------------------
  2633. # Function       :  help::rightclickX
  2634. # Description    :  Show popup menu
  2635. # Parameters     :  x & y   - position
  2636. # Return         :  Nothing
  2637. #-------------------------------------------------------------------------------
  2638. proc help::rightclickX {x y} {
  2639.  variable gw
  2640.  
  2641.  tk_popup $gw.menuX $x $y
  2642. }
  2643.  
  2644. #sch replace specialentities by characters
  2645. #-------------------------------------------------------------------------------
  2646. # Function       :  help::specialentities
  2647. # Description    :  replace specialentities by characters
  2648. # Parameters     :  text
  2649. # Return         :  text
  2650. #-------------------------------------------------------------------------------
  2651. proc help::specialentities {text} {
  2652.  set text [string map {\
  2653.       { } >     >  <     <  &   {&} "&" {&}            \
  2654.    ¡  í  ¢   ó  £  ú  ¤ ñ  ¥    Ñ  ¦ ª \
  2655.    §   º  ¨    ¿  ©   ⌐  ª   ¬  «  ½  ¬    ¼ \
  2656.    ­    ¡  ®    «  ¯   »  °    ░  ± ▒  ²   ▓ \
  2657.    ³   │  ´  ┤  µ  ╡  ¶   ╢  · ╖  ¸  ╕ \
  2658.    ¹   ╣  º   ║  »  ╗  ¼ ╝  ½ ╜  ¾ ╛ \
  2659.    ¿ ┐  À └  Á ┴  Â  ┬  Ã ├  Ä   ─ \
  2660.    Å  ┼  Æ  ╞  Ç ╟  È ╚  É ╔  Ê  ╩ \
  2661.    Ë   ╦  Ì ╠  Í ═  Î  ╬  Ï   ╧  Ð    ╨ \
  2662.    Ñ ╤  Ò ╥  Ó ╙  Ô  ╘  Õ ╒  Ö   ╓ \
  2663.    ×  ╫  Ø ╪  Ù ┘  Ú ┌  Û  █  Ü   ▄ \
  2664.    Ý ▌  Þ  ▐  ß  ▀  à α  á ß  â  Γ \
  2665.    ã π  ä   Σ  å  σ  æ  µ  ç τ  è Φ \
  2666.    é Θ  ê  Ω  ë   δ  ì ∞  í φ  î  ε \
  2667.    ï   ∩  ð    ≡  ñ ±  ò ≥  ó ≤  ô  ⌠ \
  2668.    õ ⌡  ö   ÷  ÷ ≈  ø °  ù ∙  ú · \
  2669.    û  √  ü   ⁿ  ý ²  þ  ■  ÿ      "  \" \
  2670.  } $text]
  2671.  while {[regexp -- {&#([0-9]+);} $text x num]} {
  2672.   regsub -all -- $x $text [binary format c $num] text
  2673.  }
  2674.  return $text
  2675. }
  2676. #/sch
  2677.  
  2678. #-------------------------------------------------------------------------------
  2679. # Function       :  help::focusin
  2680. # Description    :  FocusIn handler (it necessary to correct behavior if
  2681. #                :  any modal window exists)
  2682. # Parameters     :  None
  2683. # Return         :  Nothing
  2684. #-------------------------------------------------------------------------------
  2685. proc help::focusin {rw m} {
  2686.  variable _focus_w
  2687.  
  2688.  if {$rw==[winfo toplevel $rw]} {
  2689.  
  2690.   if {[grab current .]!="" && $_focus_w==""} {
  2691.    set _focus_w [grab current .]
  2692.    catch {grab release $_focus_w}
  2693.   }
  2694.  }
  2695. }
  2696.  
  2697. #-------------------------------------------------------------------------------
  2698. # Function       :  help::focusout
  2699. # Description    :  FocusOut handler (it necessary to correct behavior if
  2700. #                :  any modal window exists)
  2701. # Parameters     :  None
  2702. # Return         :  Nothing
  2703. #-------------------------------------------------------------------------------
  2704. proc help::focusout {rw m} {
  2705.  variable _focus_w
  2706.  
  2707.  if {$rw==[winfo toplevel $rw]} {
  2708.  
  2709.   if {$_focus_w!=""} {
  2710.    catch {grab $_focus_w}
  2711.    set _focus_w ""
  2712.   }
  2713.  }
  2714. }
  2715.  
  2716. proc help::img_change {name p_src} {
  2717.  variable data
  2718.  variable curfilename
  2719.  variable _images
  2720.  
  2721.  if {[info exists data($name,image,id)]} {
  2722.   if {[info exists data($p_src,image)]} {
  2723.    catch {$data($name,image,widget).text image configure $data($name,image,id) -image $data($p_src,image)}
  2724.   } else {
  2725.    if {[catch {set data($p_src,image) [image create photo -file [file join [file dirname $curfilename] $p_src]]}]} {
  2726.     catch {set imind [$data($name,image,widget).text image configure $data($name,image,id) -image $_images(broken)]}
  2727.    } else {
  2728.     catch {set imind [$data($name,image,widget).text image configure $data($name,image,id) -image $data($p_src,image)]}
  2729.    }
  2730.   }
  2731.  }
  2732. }
  2733.  
  2734. proc help::id_visible {name {vis 1}} {
  2735.  variable data
  2736.  
  2737.  catch {$data($name,names,widget).text tag configure $data($name,names,id) -elide [expr {! $vis}]}
  2738. }
  2739.  
  2740. proc help::id_change {name text} {
  2741.  variable data
  2742.  
  2743.  catch {
  2744.   set range [$data($name,names,widget).text tag ranges $data($name,names,id)]
  2745.   set names [$data($name,names,widget).text tag names [lindex $range 0]]
  2746.   $data($name,names,widget).text configure -state normal
  2747.   eval "\$data(\$name,names,widget).text delete $range"
  2748.   $data($name,names,widget).text insert [lindex $range 0] $text $names
  2749.   $data($name,names,widget).text configure -state disabled
  2750.  }
  2751. }
  2752.  
  2753. #-------------------------------------------------------------------------------
  2754. # Function       :  help::dlgfind:init
  2755. # Description    :  Create and show find dialog
  2756. # Parameters     :  mode_local  - make local(true) or global(false) find dialog
  2757. # Return         :  Nothing
  2758. #-------------------------------------------------------------------------------
  2759. proc help::dlgfind:init {{mode_local 1}} {
  2760.  variable gw
  2761.  variable index
  2762.  
  2763.  if {!$mode_local && $index==""} {return}
  2764.  
  2765.  catch {::destroy .dlgfind}
  2766.  
  2767.  toplevel .dlgfind
  2768.  wm overrideredirect .dlgfind 1
  2769.  wm transient .dlgfind $gw
  2770.  wm withdraw .dlgfind
  2771.  
  2772.  variable fnd_len 1
  2773.  
  2774.  wm resizable .dlgfind 0 0
  2775.  frame .dlgfind.f
  2776.  frame .dlgfind.btn
  2777.  pack .dlgfind.f .dlgfind.btn -side left -expand 1 -fill y -padx 3
  2778.  if {$mode_local} {
  2779.   wm title .dlgfind "Find"
  2780.   button .dlgfind.btn.f -text "Find" -width 8 -default active -command "help::dlgfind:find"
  2781.  } else {
  2782.   wm title .dlgfind "Search in all topics"
  2783.   button .dlgfind.btn.f -text "Find" -width 8 -default active -command "help::dlgfind:search"
  2784.  }
  2785.  button .dlgfind.btn.c -text "Cancel" -width 8 -command "help::dlgfind:destroy"
  2786.  pack .dlgfind.btn.f .dlgfind.btn.c -side top -expand 0 -fill x -pady 3
  2787.  
  2788.  frame .dlgfind.f.text
  2789.  frame .dlgfind.f.b
  2790.  pack .dlgfind.f.text .dlgfind.f.b -side top -fill x -expand 1 -anchor w -pady 3
  2791.  label .dlgfind.f.text.l -text "Find what: "
  2792.  entry .dlgfind.f.text.e -textvariable help::fnd_str -width 30
  2793.  pack .dlgfind.f.text.l .dlgfind.f.text.e -side left -fill y -expand 1
  2794.  .dlgfind.f.text.e selection range 0 end
  2795.  frame .dlgfind.f.b.l
  2796.  frame .dlgfind.f.b.dir
  2797.  pack .dlgfind.f.b.l .dlgfind.f.b.dir -side left -anchor s
  2798.  
  2799.  if {$mode_local} {
  2800.   frame .dlgfind.f.b.dir.p -relief flat -borderwidth 0
  2801.   frame .dlgfind.f.b.dir.b -highlightthickness 0 -relief groove -borderwidth 2
  2802.   label .dlgfind.f.b.dir.l -highlightthickness 0 -text "Direction" \
  2803.                           -relief flat -bd 0 -padx 2 -pady 0
  2804.   frame .dlgfind.f.b.dir.b.p -relief flat -bd 0 -highlightthickness 0
  2805.   frame .dlgfind.f.b.dir.f -relief flat -bd 0 -highlightthickness 0
  2806.   set height [winfo reqheight .dlgfind.f.b.dir.l]
  2807.   .dlgfind.f.b.dir.p configure -height [expr {$height/2}]
  2808.   .dlgfind.f.b.dir.b.p configure -height [expr {$height/2+$height%2+1}]
  2809.   pack .dlgfind.f.b.dir.b.p -side top -fill x
  2810.   pack .dlgfind.f.b.dir.f -in .dlgfind.f.b.dir.b -fill both -expand yes -padx 4 -pady 4
  2811.   pack .dlgfind.f.b.dir.p -side top -fill x
  2812.   pack .dlgfind.f.b.dir.b -fill both -expand yes
  2813.   place .dlgfind.f.b.dir.l -x 5 -anchor nw -y 0
  2814.  
  2815.   set f .dlgfind.f.b.dir.f
  2816.   radiobutton $f.up -text "Up" -value "-backwards" -variable help::fnd_direction
  2817.   radiobutton $f.down -text "Down" -value "-forwards" -variable help::fnd_direction
  2818.   pack $f.up $f.down -side left -fill y -expand 1
  2819.  }
  2820.  checkbutton .dlgfind.f.b.l.case -text "Match case" -onvalue "" -offvalue "-nocase" -variable help::fnd_case
  2821.  checkbutton .dlgfind.f.b.l.regexp -text "Regexp expression" -onvalue "-regexp" -offvalue "" -variable help::fnd_regexp
  2822.  pack .dlgfind.f.b.l.regexp .dlgfind.f.b.l.case -side bottom -expand 1 -anchor sw
  2823.  bind .dlgfind <Return>  ".dlgfind.btn.f configure -relief sunken; update idletasks; .dlgfind.btn.f configure -relief raised; .dlgfind.btn.f invoke"
  2824.  bind .dlgfind <Escape> "help::dlgfind:destroy"
  2825.  bind .dlgfind.f.text.e <KeyRelease> help::dlgfind:checkstate
  2826.  bind .dlgfind <FocusIn>  "help::focusin %W %m"
  2827.  bind .dlgfind <FocusOut> "help::focusout %W %m"
  2828.  bind .dlgfind <Configure> "help::focusin %W %m"
  2829.  bind .dlgfind <Destroy> "help::focusout %W %m"
  2830.  bind .dlgfind <Expose> "help::focusin %W %m"
  2831.  dlgfind:checkstate
  2832.  
  2833.  update idletasks
  2834.  set w [winfo reqwidth .dlgfind]
  2835.  set h [winfo reqheight .dlgfind]
  2836.  set x [expr [winfo rootx $gw] + ([winfo width  $gw] - $w)/2]
  2837.  set y [expr [winfo rooty $gw] + ([winfo height $gw] - $h)/2]
  2838.  wm geometry .dlgfind "${w}x${h}+${x}+${y}"
  2839.  
  2840.  wm overrideredirect .dlgfind 0
  2841.  wm deiconify .dlgfind
  2842.  
  2843.  tkwait visibility .dlgfind
  2844.  catch {focus -force .dlgfind.f.text.e}
  2845. }
  2846.  
  2847. #-------------------------------------------------------------------------------
  2848. # Function       :  help::dlgfind:destroy
  2849. # Description    :  Destroy find dialog
  2850. # Parameters     :  None
  2851. # Return         :  Nothing
  2852. #-------------------------------------------------------------------------------
  2853. proc help::dlgfind:destroy {} {
  2854.  variable gw
  2855.  
  2856.  catch {::destroy .dlgfind}
  2857.  catch {focus -force $gw.text}
  2858. }
  2859.  
  2860. #-------------------------------------------------------------------------------
  2861. # Function       :  help::dlgfind:checkstate
  2862. # Description    :  Modify state of "Find" button
  2863. # Parameters     :  None
  2864. # Return         :  Nothing
  2865. #-------------------------------------------------------------------------------
  2866. proc help::dlgfind:checkstate {} {
  2867.  variable fnd_str
  2868.  
  2869.  if {$fnd_str==""} {
  2870.   .dlgfind.btn.f configure -state disabled
  2871.  } else {
  2872.   .dlgfind.btn.f configure -state normal
  2873.  }
  2874. }
  2875.  
  2876. #-------------------------------------------------------------------------------
  2877. # Function       :  help::dlgfind:find
  2878. # Description    :  Find function
  2879. # Parameters     :  None
  2880. # Return         :  Nothing
  2881. #-------------------------------------------------------------------------------
  2882. proc help::dlgfind:find {} {
  2883.  variable gw
  2884.  variable fnd_str
  2885.  variable fnd_len
  2886.  variable fnd_case 
  2887.  variable fnd_regexp
  2888.  variable fnd_direction
  2889.  
  2890.  if {![dlgfind:checkregexp $fnd_regexp $fnd_str]} {return}
  2891.  if {$fnd_direction=="-forwards"} {set offset "+${fnd_len}chars"; set stop "end"} else {set offset "-${fnd_len}chars"; set stop "1.0"}
  2892.  set pos [$gw.text index "insert$offset"]
  2893.  if {[set findpos [eval $gw.text search $fnd_case $fnd_regexp $fnd_direction -count "help::fnd_len" -- {$fnd_str} $pos $stop]]!=""} {
  2894.   $gw.text mark set insert $findpos
  2895.   $gw.text see $findpos
  2896.   $gw.text tag remove fnd 1.0 end
  2897.   $gw.text tag remove sel 1.0 end
  2898.   $gw.text tag add sel $findpos "$findpos +${fnd_len}chars"
  2899.   $gw.text tag add fnd $findpos "$findpos +${fnd_len}chars"
  2900.  }
  2901. }
  2902.  
  2903. #-------------------------------------------------------------------------------
  2904. # Function       :  help::dlgfind:search
  2905. # Description    :  Find function (at all topics)
  2906. # Parameters     :  None
  2907. # Return         :  Nothing
  2908. #-------------------------------------------------------------------------------
  2909. proc help::dlgfind:search {} {
  2910.  variable gw
  2911.  variable fnd_str
  2912.  variable fnd_len [string length $fnd_str]
  2913.  variable fnd_case 
  2914.  variable fnd_regexp
  2915.  variable searchedtext
  2916.  variable index
  2917.  variable data
  2918.  variable abort 0
  2919.  variable stat
  2920.  variable insearch
  2921.  
  2922.  if {$insearch} {
  2923.   set abort 1
  2924.   after 250 help::dlgfind:search
  2925.   return
  2926.  }
  2927.  
  2928.  if {![dlgfind:checkregexp $fnd_regexp $fnd_str]} {return}
  2929.  dlgfind:destroy
  2930.  
  2931.  if {$searchedtext==[list $fnd_str $fnd_case $fnd_regexp]} {
  2932.   set help::curtopic ""
  2933.   show "__@SearchResult@__"
  2934.   return
  2935.  }
  2936.  set insearch 1
  2937.  set searchedtext [list $fnd_str $fnd_case $fnd_regexp]
  2938.  
  2939.  set found 0
  2940.  set data(__@SearchResult@__,title) "Search results"
  2941.  set data(__@SearchResult@__,text) "<body text=black bgcolor=#ffffd2 link=#006800><ul>"
  2942.  updatehead "__stop"
  2943.  if {$index!=""} {
  2944.   if {$fnd_case==""} {
  2945.    set fstr $fnd_str
  2946.   } else {
  2947.    set fstr [string tolower $fnd_str]
  2948.   }
  2949.   if {[set pos [lsearch -exact $index "__index"]]!=-1} {
  2950.    set topics [lreplace $index $pos $pos]
  2951.   } else {
  2952.    set topics $index
  2953.   }
  2954.   foreach topic $topics {
  2955.    set _all_text $data($topic,text)
  2956.    set totallen [string length $_all_text]
  2957.    set _text_pos 0
  2958.    set stat "Searching in $data($topic,title)..."
  2959.    update
  2960.    set outtext ""
  2961.    while {!$abort && $_text_pos!=$totallen} {
  2962.     set pos [string first "<" [string range $_all_text [expr {$_text_pos + 1024}] end]]
  2963.     if {$pos==-1} {
  2964.      set _text [string range $_all_text $_text_pos end]
  2965.      set _text_pos $totallen
  2966.     } else {
  2967.      set _text [string range $_all_text $_text_pos [expr {$_text_pos + 1024 + $pos - 1}]]
  2968.      set _text_pos [expr {$_text_pos + 1024 + $pos}]
  2969.     } 
  2970.     while {!$abort && [set pos [string first "<" $_text]]!=-1} {
  2971.      append outtext [string range $_text 0 [expr {$pos - 1}]]
  2972.      set _text [string range $_text $pos end]
  2973.      if {[set pos [string first ">" $_text]]!=-1} {
  2974.       set _text [string range $_text [incr pos] end]
  2975.      } else {
  2976.       set _text ""
  2977.      }
  2978.     }
  2979.     if {!$abort} {
  2980.      append outtext $_text
  2981.     }
  2982.    }
  2983.    if {$abort} {
  2984.     break
  2985.    } else {
  2986.     set outtext [specialentities $outtext]
  2987.     if {$fnd_regexp!=""} {
  2988.      if {[eval regexp -indices $fnd_case -- \$fnd_str \$outtext rpos]} {
  2989.       set pos [lindex $rpos 0]
  2990.       set fnd_len [expr {[lindex $rpos 1] - [lindex $rpos 0] + 1}]
  2991.      } else {
  2992.       set pos -1
  2993.      }
  2994.     } else {
  2995.      if {$fnd_case==""} {
  2996.       set _text $outtext
  2997.      } else {
  2998.       set _text [string tolower $outtext]
  2999.      }
  3000.      set pos [string first $fstr $_text]
  3001.     }  
  3002.     if {$pos!=-1} {
  3003.      set str1 [string map {{&} {&} {>} {>} {<} {<}} [string range $outtext [expr {$pos - 50}] [expr {$pos - 1}]]]
  3004.      set str2 [string map {{&} {&} {>} {>} {<} {<}} [string range $outtext $pos [expr {$pos + $fnd_len - 1}]]]
  3005.      set str3 [string map {{&} {&} {>} {>} {<} {<}} [string range $outtext [expr {$pos + $fnd_len}] [expr {$pos + $fnd_len + 70}]]]
  3006.      incr found
  3007.      append data(__@SearchResult@__,text) "<li><a href=\"$topic\">[string map {{&} {&} {>} {>} {<} {<}} $data($topic,title)]</a><br>"
  3008.      append data(__@SearchResult@__,text) "<font size=-1>...$str1<font color=#000080><b>$str2</b></font>$str3...</font><br><br>"
  3009.     }
  3010.    }
  3011.   }
  3012.  }
  3013.  if {$abort} {
  3014.   append data(__@SearchResult@__,text) "</ul><font color=#c00000>Search aborted.</font></body>"
  3015.   set searchedtext ""
  3016.  } elseif {!$found} {
  3017.   append data(__@SearchResult@__,text) "</ul><font color=#c00000>No topics found for request</font> <b>\"[string map {{&} {&} {>} {>} {<} {<}} $fnd_str]\"</b> <font color=#c00000>!</font></body>"
  3018.  } else {
  3019.   append data(__@SearchResult@__,text) "</ul></body>"
  3020.  }
  3021.  set data(__@SearchResult@__,title) "Search results ($found found)"
  3022.  set abort 0
  3023.  $gw.text configure -cursor arrow
  3024.  set stat "Done."
  3025.  set insearch 0
  3026. # updatehead "__stop"
  3027.  set help::curtopic ""
  3028.  show "__@SearchResult@__"
  3029. }
  3030.  
  3031. #-------------------------------------------------------------------------------
  3032. # Function       :  help::dlgfind:checkregexp
  3033. # Description    :  Check function
  3034. # Parameters     :  
  3035. # Return         :  Nothing
  3036. #-------------------------------------------------------------------------------
  3037. proc help::dlgfind:checkregexp {regexp val} {
  3038.  if {$regexp=="-regexp"} {
  3039.   if {[catch {regexp -- "$val" {}}]} {
  3040.    tk_dialog .help_error_in_regexp_dialog "Error in regexp" "Error in regular expression:\n\"$val\"" "" 0 "Ok"
  3041.    return 0
  3042.   } else {
  3043.    return 1
  3044.   }
  3045.  } else {
  3046.   return 1
  3047.  }
  3048. }
  3049.  
  3050. #-------------------------------------------------------------------------------
  3051. # Function       :  help::add_ext
  3052. # Description    :  Loads extensions for help package
  3053. # Parameters     :  filename    - name of file to load
  3054. # Return         :  Nothing
  3055. #-------------------------------------------------------------------------------
  3056. proc help::add_ext {filename} {
  3057.  variable gw
  3058.  variable ext_loaded
  3059.  
  3060.  set name [file tail $filename]
  3061.  if {[lsearch $ext_loaded $name]==-1} {
  3062.   if {![catch {source $filename}]} {
  3063.    lappend ext_loaded $name           
  3064.   }
  3065.  }
  3066. }
  3067.  
  3068. #===============================================================================
  3069. # Initialization section
  3070. #===============================================================================
  3071. if {[catch {package require Tcl 8.1}] || [catch {package require Tk 8.1}]} {
  3072.  error "Incompatible version of Tcl/Tk. Please update your Tcl/Tk."
  3073.  exit
  3074. }
  3075. switch -- $tcl_platform(platform) {
  3076.  "windows" {
  3077.     proc help::showurl {url} {
  3078.      eval exec [auto_execok start] [list $url] &
  3079.     }
  3080.   }
  3081.  
  3082.  "unix" {
  3083.     proc help::showurl {url} {
  3084.      exec netscape [list $url] &
  3085.     }
  3086.   }
  3087.  
  3088.  "macintosh" {
  3089.     proc help::showurl {url} {
  3090.      global env
  3091.  
  3092.      if {![info exists env(BROWSER)]} {
  3093.       set env(BROWSER) "Browse the Internet"
  3094.      }
  3095.      if {[catch {
  3096.       AppleScript execute "tell application \"$env(BROWSER)\"
  3097.                            open url \"$url\"
  3098.                            end tell"} emsg] 
  3099.         } {
  3100.       error "Error displaying $url in browser\n$emsg"
  3101.      } 
  3102.     }
  3103.   }
  3104. }
  3105.  
  3106. help::add_ext [file join [file dirname [info script]] "help_chk.tcl"]
  3107. help::add_ext [file join [file dirname [info script]] "help_2htm.tcl"]
  3108.